Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- has_field 'date_time' => (
- type => 'Compound',
- apply => [
- {
- transform => sub { DateTime->new( shift ) },
- message => 'This is not a correct date',
- }
- {
- check => sub { shift->day_of_week == 1 },
- message => 'Only Mondays allowed',
- }
- ],
- );
- has_field 'date_time.year' => (
- type => 'Integer',
- );
- has_field 'date_time.month' => (
- type => 'Integer',
- apply => [ { check => sub { my $month = shift; return $month > 0 && $month <= 12 } ]
- );
- has_field 'date_time.day' => (
- type => 'Integer',
- apply => [ { check => sub { my $day = shift; return $day > 0 && $day <= 31 } ]
- );
Add Comment
Please, Sign In to add comment