use MooseX::Types::Moose qw/Str Num Int/;
-subtype 'SimpleStr'
- => as 'Str'
+subtype SimpleStr
+ => as Str
=> where { (length($_) <= 255) && ($_ !~ m/\n/) }
=> message { "Must be a single line of no more than 255 chars" };
-subtype 'NonEmptySimpleStr'
- => as 'SimpleStr'
+subtype NonEmptySimpleStr
+ => as SimpleStr
=> where { length($_) > 0 }
=> message { "Must be a non-empty single line of no more than 255 chars" };
# XXX duplicating constraint msges since moose only uses last message
-subtype 'Password'
- => as 'NonEmptySimpleStr'
+subtype Password
+ => as NonEmptySimpleStr
=> where { length($_) > 3 }
=> message { "Must be between 4 and 255 chars" };
-subtype 'StrongPassword'
- => as 'Password'
+subtype StrongPassword
+ => as Password
=> where { (length($_) > 7) && (m/[^a-zA-Z]/) }
=> message {
"Must be between 8 and 255 chars, and contain a non-alpha char" };
-subtype 'NonEmptyStr'
- => as 'Str'
+subtype NonEmptyStr
+ => as Str
=> where { length($_) > 0 }
=> message { "Must not be empty" };
-subtype 'PositiveNum'
- => as 'Num'
+subtype PositiveNum
+ => as Num
=> where { $_ >= 0 }
=> message { "Must be a positive number" };
-subtype 'PositiveInt'
- => as 'Int'
+subtype PositiveInt
+ => as Int
=> where { $_ >= 0 }
=> message { "Must be a positive integer" };
-subtype 'SingleDigit'
- => as 'PositiveInt'
+subtype SingleDigit
+ => as PositiveInt
=> where { $_ <= 9 }
=> message { "Must be a single digit" };
use MooseX::Types::Moose 'Object';
use DBIx::Class::ResultSet;
-subtype 'ResultSet'
- => as 'Object'
+subtype ResultSet
+ => as Object
=> where { $_->isa('DBIx::Class::ResultSet') };
use DBIx::Class::Core;
use DBIx::Class::Row;
-subtype 'Row'
- => as 'Object'
+subtype Row
+ => as Object
=> where { $_->isa('DBIx::Class::Row') };
1;
use MooseX::Types::Moose qw/Object ArrayRef/;
use DateTime;
-subtype 'DateTime'
- => as 'Object'
+subtype DateTime
+ => as Object
=> where { $_->isa('DateTime') }
=> message { "Must be of the form YYYY-MM-DD HH:MM:SS" };
use DateTime::SpanSet;
-subtype 'SpanSet'
- => as 'Object'
+subtype SpanSet
+ => as Object
=> where { $_->isa('DateTime::SpanSet') };
-subtype 'TimeRangeCollection'
- => as 'ArrayRef';
+subtype TimeRangeCollection
+ => as ArrayRef;
1;
use Reaction::Types::Core 'NonEmptySimpleStr';
use Email::Valid;
-subtype 'EmailAddress'
- => as 'NonEmptySimpleStr'
+subtype EmailAddress
+ => as NonEmptySimpleStr
=> where { Email::Valid->address($_) }
=> message { "Must be a valid e-mail address" };
use MooseX::Types::Moose 'Object';
use Catalyst::Request::Upload;
-subtype 'File'
- => as 'Object'
+subtype File
+ => as Object
=> where { $_->isa('Catalyst::Request::Upload') }
=> message { "Must be a file" };