I want to check date in a form class in ZF3, when i do it like this it is nog validated with the given format, how to validate the format given?
$inputFilter->add([
'name' => 'geboortedatum',
'required' => true,
'options' => [
'format' => 'D-M-Y',
],
'filters' => [
['name' => 'StringTrim'],
],
'validators' => [
[
'name' => 'Date',
],
],
]);
There are two errors in your configuration.
The first one is where you declare your validator options (the format), which must be just after declaring the validator's name.
The second one is the format you are using. Unless you don't want to represent dates as "Wed-Jan-2020" (today's date), the correct format is
d-m-Y.According to PHP documentation, format parameters are:
The correct inputfilter declaration is:
Result: