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

Model validation: Unique rule #2

Open
ghost opened this issue Sep 14, 2017 · 1 comment
Open

Model validation: Unique rule #2

ghost opened this issue Sep 14, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Sep 14, 2017

So, i've been using this plugin and I found an issue when trying to implement the isUnique rule validation from CakePHP itself. The validation rule can't find any records because the behavior filters it, as it really should, but, since the query can't find deleted records when validating, it can't assegure the unique rule for the field too.

To solve this, we can override the validation method directly from the SoftDeletableModel class:

class SoftDeletableModel extends Model
{
    [...]

    public function isUnique($fields, $or = true) {
        // implement logic here
    }

    [...]
}

I can make a PR if you think it's fine.

@ghost
Copy link
Author

ghost commented Sep 21, 2018

@graemetait did u saw this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants