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.

Allow email validator null values

Someone can guide me to allow just null emails or correct ones? Phalcon 3, PHP7

My code:

public function validation()
{
    $validator = new Validation();

    $validator->add(
        'email',
        new EmailValidator()
    );
    return $this->validate($validator);
}


17.4k
Accepted
answer

use:

'allowEmpty' => true

example:

$validator->add(
        'email',
        new EmailValidator([
            'allowEmpty' => true
        ])
    );

Got it! Concise and clear, best regards!