Subject: | Data::FormValidator::Constraints::Dates 0.03 can't handle MMDDYYYY |
The date validation in Data::FormValidator::Constraints::Dates seems to require delimiters between components:
MM/DD/YYYY works
YYYY-MM-DD works
but not MMDDYYYY or YYYYMMDD
Without the delims, you get a validation error even on correct date.
-Jason
#!/usr/bin/perl
use strict;
use Data::FormValidator;
use Data::Dumper;
my $rules = {
validator_packages => [qw(Data::FormValidator::Constraints::Dates)]\
,
required => [ qw/dob/ ],
constraints => {
dob => {
constraint_method => "date_and_time",
params => [ \ "MMDDYYYY" ],
},
},
msgs => {
missing => "Required",
invalid => "Wrong!",
format => "%s",
constraints => {
date_and_time => "Bad date format",
},
},
};
my $data = {
dob => "02041990",
};
my $results = Data::FormValidator->check($data, $rules);
print STDERR Dumper($results->msgs);