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.

Phalcon\Validation\Validator\Regex doesn't work


I don't understand why my Regex doesn't work. There is always a error message for any passwords.

     $this->add('password', new RegexValidator(array(
               'pattern' => '.{0}|.{4,}',
               'message' => '0 or 4 char minimum'


Problem solved. I'm using now the StringLength class with the 'allowEmpty' parameter :).

     $this->add('password', new StringLength(array(
        'min' => 4,
        'messageMinimum' => '4 char minimum',
        'allowEmpty' => true


just if you didnt know this website. ( sorry if you do ) its explain on the right


Yes I know this website. But the problem wasn't is in my regex because in my view this regex works well. But server side there is a bug with the pattern attribute.

You have to use a PCRE compatible regex: "pattern" => "/.{0}|.{4,}/",


Ok Thanks Andres. I'll try this next time if I have to use the Regex class.