Vegas CMF Validation



You can use this trait to change validator behavior. Class will validate not only single values but also each of arrayed values.


use Phalcon\Validation\Validator;
use Phalcon\Validation\Message;

class Email extends Validator
    use \Vegas\Validation\ValidatorTrait;

    protected function validateSingle($value)
        if ($value && !filter_var($value, FILTER_VALIDATE_EMAIL)) {
            $this->validator->appendMessage(new Message($this->getMessage(), $this->attribute, 'Email'));
    return false;

    return true;

    private function getMessage()
    $message = $this->getOption('message');
    if (!$message) {
    $message = 'One of the emails is not valid.';

    return $message;

All validators from Vegas CMF Validation package are using Vegas\Validation\ValidatorTrait to validate both single and array values.