Home > Backend Development > PHP Tutorial > Verification error in model in phalcon

Verification error in model in phalcon

WBOY
Release: 2016-09-28 08:54:07
Original
1364 people have browsed it

Error message

<code>Catchable fatal error: Argument 1 passed to Phalcon\Mvc\Model::validate() must implement interface Phalcon\ValidationInterface, instance of Phalcon\Mvc\Model\Validator\PresenceOf given in C:\wamp\www\test\apps\models\Robots.php on line 49</code>
Copy after login
Copy after login

Verification code in model

<code>use Phalcon\Mvc\Model\Validator\PresenceOf;
use Phalcon\Mvc\Model\Validator\Uniqueness;

public function validation()
    {
        $this->validate(
            new PresenceOf(
                array(
                    "field" => "name",
                    "message" => self::NAME_NOT_EMPTY
                )
            )
        );
        $this->validate(
            new Uniqueness(
                array(
                    'field' => 'code',
                    'message' => self::ERR_CODE_NOT_UNID
                )
            )
        );
        if ($this->validationHasFailed() == true) {
            return false;
        }

        return true;
    }</code>
Copy after login
Copy after login

Reply content:

Error message

<code>Catchable fatal error: Argument 1 passed to Phalcon\Mvc\Model::validate() must implement interface Phalcon\ValidationInterface, instance of Phalcon\Mvc\Model\Validator\PresenceOf given in C:\wamp\www\test\apps\models\Robots.php on line 49</code>
Copy after login
Copy after login

Verification code in model

<code>use Phalcon\Mvc\Model\Validator\PresenceOf;
use Phalcon\Mvc\Model\Validator\Uniqueness;

public function validation()
    {
        $this->validate(
            new PresenceOf(
                array(
                    "field" => "name",
                    "message" => self::NAME_NOT_EMPTY
                )
            )
        );
        $this->validate(
            new Uniqueness(
                array(
                    'field' => 'code',
                    'message' => self::ERR_CODE_NOT_UNID
                )
            )
        );
        if ($this->validationHasFailed() == true) {
            return false;
        }

        return true;
    }</code>
Copy after login
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template