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

Add not_match validator #141

Open
mattremmel opened this issue Jan 22, 2021 · 4 comments
Open

Add not_match validator #141

mattremmel opened this issue Jan 22, 2021 · 4 comments

Comments

@mattremmel
Copy link

This would be nice to have for me, specifically for cases where all inputs are valid except for a single case (Uuid::nil()), or where two fields can contain similar types of data, but they can't exactly match. I haven't spent much time looking at the internals, but i'd be willing to try to write the code if its feasible to do.

@xFrednet
Copy link
Contributor

xFrednet commented Jan 24, 2021

I like the idea if negating a validation. This would be the negation of the match validation if I'm right. The question is what syntax could be used. Do you have a suggestion how to write this? 🙃 @mattremmel

@mattremmel
Copy link
Author

I was originally thinking just an inverted version of must_match, but as I think about it, I'm not sure if that is needlessly restrictive. Its probably possible to do a generic not(...), that would would allow for things like #[validate(not(length(min =1, max = 3)))], the downside being another level of parenthesis around everything, but gaining increased flexibility.

@Keats
Copy link
Owner

Keats commented Jan 25, 2021

I'm not sure we want to add generic not. match is one that might need it but the other validator seem to not need it. I mean, how often do you need something like #[validate(not(length(min =1, max = 3)))]

@IniterWorker
Copy link
Contributor

I second @Keats. This is not the way to go. This could be solved with a custom validator.

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

4 participants