Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.0.1] Uniqueness validator not implement Phalcon\ValidationInterface #12178

Closed
wolftankk opened this issue Aug 30, 2016 · 1 comment
Closed
Labels
not a bug Reported issue is not a bug

Comments

@wolftankk
Copy link

wolftankk commented Aug 30, 2016

Uncaught TypeError: Argument 1 passed to Phalcon\Mvc\Model::validate() must implement interface Phalcon\ValidationInterface, instance of Phalcon\Validation\Validator\Uniqueness
use Phalcon\Mvc\Model,
    Phalcon\Db\Column,
    Phalcon\Validation\Validator\Uniqueness;    

class Test extends Model {
    public function validation() {
        $a = new Uniqueness(
            array(
                "field"   => "telephone",
                "message" => "error"
            )
        );
        return $this->validationHasFailed() != true;
    }
}

Uniqueness has implemented Phalcon\Validation\ValidatorInterface

@Jurigag
Copy link
Contributor

Jurigag commented Aug 30, 2016

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

This is code from 2.0.x. Check blog post about new validation https://blog.phalconphp.com/post/phalcon-3-0-0-released

It should look like this:

public function validation()
{
     $validator = new Validation();

        $validator->add(
            'telephone',
            new Uniqueness([
                'message' => 'error',
            ])
        );

        return $this->validate($validator);
}

@sergeyklay sergeyklay added the not a bug Reported issue is not a bug label Aug 30, 2016
@ruudboon ruudboon mentioned this issue Nov 29, 2016
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not a bug Reported issue is not a bug
Projects
None yet
Development

No branches or pull requests

3 participants