We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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?



145.0k
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
]);