Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Validators with empty values

I'm currently working on a project that relies heavily on the form builder, there's a customer profile form that has all information required on a customer. There's a contact number and email field that do NOT have the PresenceOf validator and therefore are not required fields however, the validators seem to validate even an empty value so Phalcon\Validation\Validator\Email will say a blank field isn't a valid email...

Anyway to change this without creating my own validators replicating the behaviour just not with empty fields?



8.2k
Accepted
answer

I've just looked at the source of Phalcon 2.0 and can see that there is an option "allowEmpty" which is what I was after. Shame it isn't documented anywhere!

https://github.com/phalcon/cphalcon/blob/2.0.0/phalcon/validation/validator/email.zep#L51