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

Be able to compose Pattern list with OR expression #157

Open
sanmibuh opened this issue Oct 6, 2019 · 3 comments
Open

Be able to compose Pattern list with OR expression #157

sanmibuh opened this issue Oct 6, 2019 · 3 comments

Comments

@sanmibuh
Copy link

sanmibuh commented Oct 6, 2019

Nowadays @pattern validator is able to match a list of patterns. But the validation passes if all of pattern matches.
It could be helpful having a @Pattern.List configuration for tell the need to pass all (AND composition) or at least one (OR composition)

@emmanuelbernard
Copy link
Contributor

Hey there, I think we discussed it in the past but I can't recall the reason why we did not execute.
Have you explore the implications on the spec and group system? The API is the easy part even though what you propose does not allow for nested AND/OR structures.

@sanmibuh
Copy link
Author

sanmibuh commented Oct 8, 2019

I have put the same question in the official forum https://discourse.hibernate.org/t/multiple-pattern-validator-with-or/3327

I know that the proposal is simple, but accepting nested AND / OR structure IMHO is cross for all validations. I mean, it could be awesome for grouping different validations. Nowadays Hibernates bean validation implementation could do with @ConstraintComposition annotation. https://docs.jboss.org/hibernate/validator/5.3/reference/en-US/html_single/#section-boolean-constraint-composition.

But this case is a more simple case. Pattern.List actually groups all patterns with AND composition. With this change, the implementation could read this parameter and apply the composition with the desired union operator without having the more complex cross @ConstraintComposition annotation.

Maybe, as the reference implementation could do this, why not adding this annotation as API spec? It could be awesome

@emmanuelbernard
Copy link
Contributor

Ah I see, this would be for Pattern specifically. I read too quickly.

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

2 participants