You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment there is no mechanism to define the group sequence validation at runtime. Hibernate Validator has its own mechanism, through @GroupSequenceProvider annotation and DefaultGroupSequenceProvider interface.
Inspired by the Hibernate's solution, my suggestion is to add the attribute "provider" to the @GroupSequence annotation which expects a reference to a class that implements the interface "GroupSequenceProvider".
One common use case GroupSequenceProvider solves for us is conditional validation: We have many beans where some fields should only be validated when some other fields have a value.
There is for example this library that provides conditional constraint annotations such as NotEmptyWhen. It's quite concise, but it is also not-standard, requires a complicated, messy implementations, needs an additional dummy annotation for each normal annotation (NotEmptyWhen for NotEmpty etc.), which is also does not play well with custom constraint annotations.
I find GroupSequenceProvider to be a nice way to handle conditional validation in a mostly declarative manner, that does not require much boilerplate.
This would also combine well with groups for the @Valid annotation #269
For reference, an example of how GroupSequenceProvider could be used:
At the moment there is no mechanism to define the group sequence validation at runtime. Hibernate Validator has its own mechanism, through @GroupSequenceProvider annotation and DefaultGroupSequenceProvider interface.
Inspired by the Hibernate's solution, my suggestion is to add the attribute "provider" to the @GroupSequence annotation which expects a reference to a class that implements the interface "GroupSequenceProvider".
More info: Hibernate Validator docs.
The text was updated successfully, but these errors were encountered: