How to obtain ConstraintValidatorContext?

前端 未结 3 762
予麋鹿
予麋鹿 2021-01-13 20:31

I am writing code that has explicit call to Bean Validation (JSR-303) something like this:

public class Example {

    @DecimalMin(value = \"0\")
    private         


        
3条回答
  •  感情败类
    2021-01-13 21:13

    You should declare a group for the constraints you validate in that case. Then you can call the normal validation for that group. See sections 2.1.1.2 and section 3.4 of the spec for group definitions and their semantics. For validating the group, you then just need to call Validator.validate(T Object, Class... groups). There is no need to mess around with the ConstraintValidatorContext in this case.

提交回复
热议问题