We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

AllowEmpty for multiple fields in one validator

How can I allowEmpty values for multiple fields in one validator ?

Example:


$validator->add(
[
        'fname', 'lname'
],
new Alpha ([
    'message' => [
        'fname' => 'Invalid first name',
        'lname' => 'Invalid last name'
    ]
]);
edited Jul '18

This code:

'allowEmpty' => [
    'fname' => true
    'lname' => false
]

Doesn't work? If not then create issue on github, it's kind of bug that it's not implemented. If you need to allow both of fields to allowEmpty then just allowEmpty' => true should work, not sure about for example a case above.