zend-framework2zend-validate

zf2 validator - valid only if date is a weekday


Using ZF2 \Zend\Validate, is it possible to validate a date only if it is a weekday? So weekends, regardless of month or year, will fail the validation?

The input is a normal text field.


Solution

  • I don't think that Zend\Validate has already a validator to check that.

    You'll probably need to write your own custom validator to do your check.

    Have a look at this answer to see how to perform the actual check (actually that answer check the converse, but it'll be easy to adapt it)