You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When passing a format to the datetime rule, it even accepts dates which are in another format because of the default behavior of the \DateTime implementation.
Use Case
$validator->required('date')->datetime('Ymd');
$validator->validate(['date' => '12111978']); // 12 november 1978
The above will give true while 19 can never be a correct month, nor can 78 be a correct day.
When issuing a validation using the datetime rule, it must adhere to the format AND also verify if the date portions are the same. This ensures that the overflow is not used and dates such as above and
31-02-2015 are considered invalid.
The text was updated successfully, but these errors were encountered:
That is a very excellent point, @NickBelhomme. I tend to forget this auto behaviour of \DateTime. Even though it can be helpful at times (start bill cycle on 29th of February == 1st of March), the functionality is not that useful when validating ;)
Context
When passing a format to the datetime rule, it even accepts dates which are in another format because of the default behavior of the \DateTime implementation.
Use Case
The above will give true while 19 can never be a correct month, nor can 78 be a correct day.
The issue lies within this part of the code:
which gives:
https://github.com/particle-php/Validator/blob/master/src/Particle/Validator/Rule/Datetime.php#L75
Acceptance Criteria
When issuing a validation using the datetime rule, it must adhere to the format AND also verify if the date portions are the same. This ensures that the overflow is not used and dates such as above and
31-02-2015 are considered invalid.
The text was updated successfully, but these errors were encountered: