Guest User

Untitled

a guest
Mar 14th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. has_field 'date_time' => (
  2. type => 'Compound',
  3. apply => [
  4. {
  5. transform => sub { DateTime->new( shift ) },
  6. message => 'This is not a correct date',
  7. }
  8. {
  9. check => sub { shift->day_of_week == 1 },
  10. message => 'Only Mondays allowed',
  11. }
  12. ],
  13. );
  14. has_field 'date_time.year' => (
  15. type => 'Integer',
  16. );
  17. has_field 'date_time.month' => (
  18. type => 'Integer',
  19. apply => [ { check => sub { my $month = shift; return $month > 0 && $month <= 12 } ]
  20. );
  21. has_field 'date_time.day' => (
  22. type => 'Integer',
  23. apply => [ { check => sub { my $day = shift; return $day > 0 && $day <= 31 } ]
  24. );
Add Comment
Please, Sign In to add comment