Home  >  Article  >  Backend Development  >  Verification error in model in phalcon

Verification error in model in phalcon

WBOY
WBOYOriginal
2016-09-28 08:54:071299browse

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>

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>

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>

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>
Statement:
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