zendframework / zend-validator

Validator component from Zend Framework
BSD 3-Clause "New" or "Revised" License
181 stars 136 forks source link

Strict mode for Date validator #275

Closed michalbundyra closed 4 years ago

michalbundyra commented 4 years ago

Input must be always in the defined format and must be the same as output of format method of DateTime.

Strict mode is set to false by default to keep BC.

Currently to the validator we can provide integer, double, array, string or DateTimeInterface value. In my opinion as validator has set format we should check if the input value has exactly the same format as set. In strict mode we are comparing if:

$input === DateTime::createFromFormat($format, $input)->format($format);

Resolve #33 Fix zendframework/zendframework#6407

I would see strict mode by default enabled in v3, or ONLY strict mode in v3. Thoughts?

/cc @svycka @gianarb