Aion
    
    
  
  
  
view release on metacpan or search on metacpan
lib/Aion/Types.md view on Meta::CPAN
Strings, include numbers.
```perl
1.1 ~~ Str         # -> 1
"" ~~ Str          # -> 1
1.1.0 ~~ Str       # -> ""
```
## Uni
Unicode strings: with utf8-flag or decode to utf8 without error.
```perl
"â" ~~ Uni    # -> 1
123 ~~ Uni    # -> ""
do {no utf8; "â" ~~ Uni}    # -> 1
```
## Bin
Binary strings: without utf8-flag and octets with numbers less then 128.
```perl
123 ~~ Bin    # -> 1
"z" ~~ Bin    # -> 1
"â" ~~ Bin    # -> ""
do {no utf8; "â" ~~ Bin }   # -> ""
```
## StartsWith\[S]
The string starts with `S`.
```perl
"Hi, world!" ~~ StartsWith["Hi,"]	# -> 1
"Hi world!" ~~ StartsWith["Hi,"]	# -> ""
```
    
  
  
  lib/Aion/Types.pm view on Meta::CPAN
	subtype "Item", as &Any;
		subtype "Bool", as &Item, where { ref $_ eq "" and /^(1|0|)\z/ };
		subtype "Enum[A...]", as &Item, where { $_ ~~ ARGS };
		subtype "Maybe[A]", as &Item, where { !defined($_) || A->test };
		subtype "Undef", as &Item, where { !defined $_ };
		subtype "Defined", as &Item, where { defined $_ };
			subtype "Value", as &Defined, where { "" eq ref $_ };
				subtype "Version", as &Value, where { "VSTRING" eq ref \$_ };
				my $init_limit = sub { if(@{&ARGS} == 1) { SELF->{min} = 0; SELF->{max} = A } else { SELF->{min} = A; SELF->{max} = B } };
				subtype "Str", as &Value, where { "SCALAR" eq ref \$_ };
					subtype "Uni", as &Str,	where { utf8::is_utf8($_) || /[\x80-\xFF]/a };
					subtype "Bin", as &Str, where { !utf8::is_utf8($_) && !/[\x80-\xFF]/a };
					subtype "NonEmptyStr", as &Str,	where { /\S/ };
					subtype "StartsWith[S]", as &Str,
						init_where { M = qr/^${\ quotemeta A}/ },
						where { $_ =~ M };
					subtype "EndsWith[S]", as &Str,
						init_where { N = qr/${\ quotemeta A}$/ },
						where { $_ =~ N };
					subtype "Email", as &Str, where { /@/ };
					subtype "Tel", as &Str, where { /^\+\d{7,}\z/ };
					subtype "Url", as &Str, where { /^https?:\/\// };
    
  
  
  lib/Aion/Types.pm view on Meta::CPAN
=head2 Str
Strings, include numbers.
	1.1 ~~ Str         # -> 1
	"" ~~ Str          # -> 1
	1.1.0 ~~ Str       # -> ""
=head2 Uni
Unicode strings: with utf8-flag or decode to utf8 without error.
	"â" ~~ Uni    # -> 1
	123 ~~ Uni    # -> ""
	do {no utf8; "â" ~~ Uni}    # -> 1
=head2 Bin
Binary strings: without utf8-flag and octets with numbers less then 128.
	123 ~~ Bin    # -> 1
	"z" ~~ Bin    # -> 1
	"â" ~~ Bin    # -> ""
	do {no utf8; "â" ~~ Bin }   # -> ""
=head2 StartsWith[S]
The string starts with C<S>.
	"Hi, world!" ~~ StartsWith["Hi,"]	# -> 1
	"Hi world!" ~~ StartsWith["Hi,"]	# -> ""
=head2 EndsWith[S]
    
  
  
  use common::sense; use open qw/:std :utf8/;  use Carp qw//; use File::Basename qw//; use File::Find qw//; use File::Slurper qw//; use File::Spec qw//; use File::Path qw//; use Scalar::Util qw//;  use Test::More 0.98;  BEGIN {     $SIG{__DIE__} = sub ...
# # NAME
# 
# Aion - поÑÑмодеÑниÑÑÑÐºÐ°Ñ Ð¾Ð±ÑекÑÐ½Ð°Ñ ÑиÑÑема Ð´Ð»Ñ Perl 5, ÑÐ°ÐºÐ°Ñ ÐºÐ°Ðº «Mouse», «Moose», «Moo», «Mo» и «M», но Ñ ÑлÑÑÑениÑми
# 
# # VERSION
# 
# 0.3
# 
# # SYNOPSIS
# 
    
  
  
  t/aion/type.t view on Meta::CPAN
use common::sense; use open qw/:std :utf8/;  use Carp qw//; use File::Basename qw//; use File::Find qw//; use File::Slurper qw//; use File::Spec qw//; use File::Path qw//; use Scalar::Util qw//;  use Test::More 0.98;  BEGIN {     $SIG{__DIE__} = sub ...
# 
# Aion::Type - class of validators
# 
# # SYNOPSIS
# 
subtest 'SYNOPSIS' => sub { 
use Aion::Type;
my $Int = Aion::Type->new(name => "Int", test => sub { /^-?\d+$/ });
::is scalar do {12   ~~ $Int}, "1", '12   ~~ $Int # => 1';
    
  
  
  t/aion/types.t view on Meta::CPAN
use common::sense; use open qw/:std :utf8/;  use Carp qw//; use File::Basename qw//; use File::Find qw//; use File::Slurper qw//; use File::Spec qw//; use File::Path qw//; use Scalar::Util qw//;  use Test::More 0.98;  BEGIN {     $SIG{__DIE__} = sub ...
# 
# Aion::Types is a library of validators. And it makes new validators
# 
# # SYNOPSIS
# 
subtest 'SYNOPSIS' => sub { 
use Aion::Types;
BEGIN {
    subtype SpeakOfKitty => as StrMatch[qr/\bkitty\b/i],
    
  
  
  t/aion/types.t view on Meta::CPAN
# Strings, include numbers.
# 
done_testing; }; subtest 'Str' => sub { 
::is scalar do {1.1 ~~ Str}, scalar do{1}, '1.1 ~~ Str         # -> 1';
::is scalar do {"" ~~ Str}, scalar do{1}, '"" ~~ Str          # -> 1';
::is scalar do {1.1.0 ~~ Str}, scalar do{""}, '1.1.0 ~~ Str       # -> ""';
# 
# ## Uni
# 
# Unicode strings: with utf8-flag or decode to utf8 without error.
# 
done_testing; }; subtest 'Uni' => sub { 
::is scalar do {"â" ~~ Uni}, scalar do{1}, '"â" ~~ Uni    # -> 1';
::is scalar do {123 ~~ Uni}, scalar do{""}, '123 ~~ Uni    # -> ""';
::is scalar do {do {no utf8; "â" ~~ Uni}}, scalar do{1}, 'do {no utf8; "â" ~~ Uni}    # -> 1';
# 
# ## Bin
# 
# Binary strings: without utf8-flag and octets with numbers less then 128.
# 
done_testing; }; subtest 'Bin' => sub { 
::is scalar do {123 ~~ Bin}, scalar do{1}, '123 ~~ Bin    # -> 1';
::is scalar do {"z" ~~ Bin}, scalar do{1}, '"z" ~~ Bin    # -> 1';
::is scalar do {"â" ~~ Bin}, scalar do{""}, '"â" ~~ Bin    # -> ""';
::is scalar do {do {no utf8; "â" ~~ Bin }}, scalar do{""}, 'do {no utf8; "â" ~~ Bin }   # -> ""';
# 
# ## StartsWith\[S]
# 
# The string starts with `S`.
# 
done_testing; }; subtest 'StartsWith\[S]' => sub { 
::is scalar do {"Hi, world!" ~~ StartsWith["Hi,"]}, scalar do{1}, '"Hi, world!" ~~ StartsWith["Hi,"]	# -> 1';
::is scalar do {"Hi world!" ~~ StartsWith["Hi,"]}, scalar do{""}, '"Hi world!" ~~ StartsWith["Hi,"]	# -> ""';
    
  
  
  
( run in 1.300 second using v1.01-cache-2.11-cpan-a1d94b6210f )