Aion

 view release on metacpan or  search on metacpan

lib/Aion/Types.md  view on Meta::CPAN

					Bin
					NonEmptyStr
					StartsWith[start]
					EndsWith[end]
					Email
					Tel
					Url
					Path
					Html
					StrDate
					StrDateTime
					StrMatch[regexp]
					PackageName
						ClassName
						RoleName
					Join[separator]
					Split[separator]
					StrRat
					Num
						PositiveNum
						Int

lib/Aion/Types.md  view on Meta::CPAN


## StrDate

Дата в формате `yyyy-mm-dd`.

```perl
"2001-01-12" ~~ StrDate # -> 1
"01-01-01" ~~ StrDate   # -> ""
```

## StrDateTime

Дата и время в формате `yyyy-mm-dd HH:MM:SS`.

```perl
"2012-12-01 00:00:00" ~~ StrDateTime  # -> 1
"2012-12-01 00:00:00 " ~~ StrDateTime # -> ""
```

## StrMatch[regexp]

Сопоставляет строку с регулярным выражением.

```perl
' abc ' ~~ StrMatch[qr/abc/]  # -> 1
' abbc ' ~~ StrMatch[qr/abc/] # -> ""
```

lib/Aion/Types.pm  view on Meta::CPAN

						where { $_ =~ M };
					subtype "EndsWith[end]", 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?:\/\// };
					subtype "Path", as &Str, where { /^\// };
					subtype "Html", as &Str, where { /^\s*<(!doctype\s+html|html)\b/i };
					subtype "StrDate", as &Str, where { /^\d{4}-\d{2}-\d{2}\z/ };
					subtype "StrDateTime", as &Str, where { /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\z/ };
					subtype "StrMatch[regexp]", as &Str, where { $_ =~ A };
					subtype "PackageName", as &Str, where { no utf8; use bytes; /^(?:[a-z]\w*(?:::[a-z]\w*)*)\z/ia };
						subtype "ClassName", as &PackageName, where { !!$_->can('new') };
						subtype "RoleName", as &PackageName, where { !$_->can('new') && !!(@{"$_\::ISA"} || first { *{$_}{CODE} } values %{"$_\::"}) };
					subtype "StrRat", as &Str, where { m!\s*/\s*!? &Num->include($`) && &Num->include($`): &Num->test };
					subtype "Num", as &Str, where { looks_like_number($_) && /[\dfn]\z/i };
						subtype "Int", as &Num,	where { /^[-+]?\d+\z/ };

			subtype "Ref", as &Defined, where { "" ne ref $_ };
				subtype "Tied`[class]", as &Ref,

lib/Aion/Types.pm  view on Meta::CPAN

						Bin
						NonEmptyStr
						StartsWith[start]
						EndsWith[end]
						Email
						Tel
						Url
						Path
						Html
						StrDate
						StrDateTime
						StrMatch[regexp]
						PackageName
							ClassName
							RoleName
						Join[separator]
						Split[separator]
						StrRat
						Num
							PositiveNum
							Int

lib/Aion/Types.pm  view on Meta::CPAN

	" <!doctype html>" ~~ Html # -> 1
	" <html1>" ~~ Html         # -> ""

=head2 StrDate

Date in C<yyyy-mm-dd> format.

	"2001-01-12" ~~ StrDate # -> 1
	"01-01-01" ~~ StrDate   # -> ""

=head2 StrDateTime

Date and time in the format C<yyyy-mm-dd HH:MM:SS>.

	"2012-12-01 00:00:00" ~~ StrDateTime  # -> 1
	"2012-12-01 00:00:00 " ~~ StrDateTime # -> ""

=head2 StrMatch[regexp]

Matches a string against a regular expression.

	' abc ' ~~ StrMatch[qr/abc/]  # -> 1
	' abbc ' ~~ StrMatch[qr/abc/] # -> ""

=head2 ClassName

t/aion/types.t  view on Meta::CPAN

# 					Bin
# 					NonEmptyStr
# 					StartsWith[start]
# 					EndsWith[end]
# 					Email
# 					Tel
# 					Url
# 					Path
# 					Html
# 					StrDate
# 					StrDateTime
# 					StrMatch[regexp]
# 					PackageName
# 						ClassName
# 						RoleName
# 					Join[separator]
# 					Split[separator]
# 					StrRat
# 					Num
# 						PositiveNum
# 						Int

t/aion/types.t  view on Meta::CPAN

# 
# ## StrDate
# 
# Дата в формате `yyyy-mm-dd`.
# 
::done_testing; }; subtest 'StrDate' => sub { 
local ($::_g0 = do {"2001-01-12" ~~ StrDate}, $::_e0 = do {1}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '"2001-01-12" ~~ StrDate # -> 1' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {"01-01-01" ~~ StrDate}, $::_e0 = do {""}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '"01-01-01" ~~ StrDate   # -> ""' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;

# 
# ## StrDateTime
# 
# Дата и время в формате `yyyy-mm-dd HH:MM:SS`.
# 
::done_testing; }; subtest 'StrDateTime' => sub { 
local ($::_g0 = do {"2012-12-01 00:00:00" ~~ StrDateTime}, $::_e0 = do {1}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '"2012-12-01 00:00:00" ~~ StrDateTime  # -> 1' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::...
local ($::_g0 = do {"2012-12-01 00:00:00 " ~~ StrDateTime}, $::_e0 = do {""}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '"2012-12-01 00:00:00 " ~~ StrDateTime # -> ""' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef ...

# 
# ## StrMatch[regexp]
# 
# Сопоставляет строку с регулярным выражением.
# 
::done_testing; }; subtest 'StrMatch[regexp]' => sub { 
local ($::_g0 = do {' abc ' ~~ StrMatch[qr/abc/]}, $::_e0 = do {1}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '\' abc \' ~~ StrMatch[qr/abc/]  # -> 1' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {' abbc ' ~~ StrMatch[qr/abc/]}, $::_e0 = do {""}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '\' abbc \' ~~ StrMatch[qr/abc/] # -> ""' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;



( run in 0.862 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )