Hi,
I think that current status of the bean validation is little restricted or counter intuitive.
In our application we have such a case:
1) Constraints should be evaluated in particular order. (cheap to expensive)
2) Constraints should not be evaluated after a violation per field.
3) All fields should be validated.
For first two, groupsequence is fitting very good. However for my 3rd requirement I could not find a way to solve.
Code:
public class AccountBean {
@CheepValidation
@ExpensiveValidation
@VeryExpensiveValidation
private String name;
@CheepValidation
@ExpensiveValidation
@VeryExpensiveValidation
private String surname
}
For example,
Let's say that, for name field VeryExpensiveValidationconstraint is violated and for surname field ExpensiveValidation constraint is violated.
For this case I am expecting such a scenario. I should display:
For field name: Only VeryExpensiveValidation error message
For field surname: Only ExpensiveValidation error message
Note that for field surname we did not evaluate VeryExpensiveValidationconstraint. I started to think that after reading spec and making practice validation framework is great but in terms of ordering constraint for per field is very difficult. (I could not find at least.)
Intuitively I was expecting an annotation like
OrderedValidation.
Code:
public class AccountBean {
@OrderedValidation(order = {CheepValidation,ExpensiveValidation,VeryExpensiveValidation}, stopOnError=true)
@CheepValidation
@ExpensiveValidation
@VeryExpensiveValidation
private String name;
@OrderedValidation(order = {CheepValidation,ExpensiveValidation,VeryExpensiveValidation}, stopOnError=true)
@CheepValidation
@ExpensiveValidation
@VeryExpensiveValidation
private String surname
}
Forgive my ignorance please if I made a mistake. I would like thank again for such a great validation api.
Thanks