loose comparison or strict comparison in dateFormat validation method?
loose comparison or strict comparison in dateFormat validation method?
hzhong
Posts: 26Questions: 9Answers: 0
in Bug reports
Hello,
When using dateFormat validation as
->validator( Validate::dateFormat( 'Y' ) )
I found it does not report validation error if input is not in the format of ''Y A full numeric representation of a year, 4 digits''. I found it's because this line
For example, if the input is 11
$val = '11';
$format = 'Y';
$date = DateTime::createFromFormat($format, $val);
$date->format($format) == $val;
The above code uses loose comparison and evaluates True. Strict comparison would evaluate False and report validation error.
Replies
Thanks for flagging that up! Fix committed here.
Regards,
Allan