Aion

 view release on metacpan or  search on metacpan

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

					Bin
					NonEmptyStr
					StartsWith
					EndsWith
					Email
					Tel
					Url
					Path
					Html
					StrDate
					StrDateTime
					StrMatch[qr/.../]
					ClassName[A]
					RoleName[A]
					Rat
					Num
						PositiveNum
						Int
							PositiveInt
							Nat
			Ref

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


## StrDate

The date is format `yyyy-mm-dd`.

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

## StrDateTime

The dateTime is format `yyyy-mm-dd HH:MM:SS`.

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

## StrMatch[qr/.../]

Match value with regular expression.

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

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

						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?:\/\// };
					subtype "Path", as &Str, where { /^\// };
					subtype "Html", as &Str, where { /^\s*<(!doctype|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[qr/.../]", as &Str, where { $_ =~ A };
					subtype "ClassName", as &Str, where { !!$_->can('new') };
					subtype "RoleName", as &Str, where { !!$_->can('requires') };

					subtype "Num", as &Str, where { looks_like_number($_) && /[\dfn]\z/i };
						subtype "PositiveNum", as &Num, where { $_ >= 0 };
						subtype "Int", as &Num,	where { /^-?\d+\z/ };
							subtype "PositiveInt", as &Int, where { $_ >= 0 };
							subtype "Nat", as &Int, where { $_ > 0 };
					subtype "Rat", as &Str, where { &Num->test || /^(-?\d+(\/\d+)?)\z/in };

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

						Bin
						NonEmptyStr
						StartsWith
						EndsWith
						Email
						Tel
						Url
						Path
						Html
						StrDate
						StrDateTime
						StrMatch[qr/.../]
						ClassName[A]
						RoleName[A]
						Rat
						Num
							PositiveNum
							Int
								PositiveInt
								Nat
				Ref

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

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

=head2 StrDate

The date is format C<yyyy-mm-dd>.

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

=head2 StrDateTime

The dateTime is 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[qr/.../]

Match value with regular expression.

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

=head2 ClassName

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

# 					Bin
# 					NonEmptyStr
# 					StartsWith
# 					EndsWith
# 					Email
# 					Tel
# 					Url
# 					Path
# 					Html
# 					StrDate
# 					StrDateTime
# 					StrMatch[qr/.../]
# 					ClassName[A]
# 					RoleName[A]
# 					Rat
# 					Num
# 						PositiveNum
# 						Int
# 							PositiveInt
# 							Nat
# 			Ref

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

# 
# ## StrDate
# 
# The date is format `yyyy-mm-dd`.
# 
done_testing; }; subtest 'StrDate' => sub { 
::is scalar do {"2001-01-12" ~~ StrDate}, scalar do{1}, '"2001-01-12" ~~ StrDate    # -> 1';
::is scalar do {"01-01-01" ~~ StrDate}, scalar do{""}, '"01-01-01" ~~ StrDate    # -> ""';

# 
# ## StrDateTime
# 
# The dateTime is format `yyyy-mm-dd HH:MM:SS`.
# 
done_testing; }; subtest 'StrDateTime' => sub { 
::is scalar do {"2012-12-01 00:00:00" ~~ StrDateTime}, scalar do{1}, '"2012-12-01 00:00:00" ~~ StrDateTime     # -> 1';
::is scalar do {"2012-12-01 00:00:00 " ~~ StrDateTime}, scalar do{""}, '"2012-12-01 00:00:00 " ~~ StrDateTime    # -> ""';

# 
# ## StrMatch[qr/.../]
# 
# Match value with regular expression.
# 
done_testing; }; subtest 'StrMatch[qr/.../]' => sub { 
::is scalar do {' abc ' ~~ StrMatch[qr/abc/]}, scalar do{1}, '\' abc \' ~~ StrMatch[qr/abc/]    # -> 1';
::is scalar do {' abbc ' ~~ StrMatch[qr/abc/]}, scalar do{""}, '\' abbc \' ~~ StrMatch[qr/abc/]   # -> ""';



( run in 0.399 second using v1.01-cache-2.11-cpan-05444aca049 )