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.

model validation() is not calling

I really confuse why the model validation() function is not calling. Code on customers model as

    public function validation()
        {
            print_r('method called');
            // name
            $this->validate(new PresenceOf(array(
                "field" => "name",
                "message" => 'User name is required'
            )));

            return $this->validationHasFailed() != true;
        }

On validation fail, default message name is required is showing.

I tried with: php 5.6.11 and 5.6.19 phalcon 2.0.9 and 2.1.0

Any one have any idea?



106.7k
Accepted
answer

Beacause phaclon first before validation checks for not nulls. If you want to get rid of it then do this:

\Phalcon\Mvc\Model::setup([
    'notNullValidations' => false
]);