validation icon indicating copy to clipboard operation
validation copied to clipboard

ConstraintValidator about why is passed ConstraintValidatorContext isValid method, ValidationContext is not

Open Sheldon66-Huang opened this issue 1 year ago • 1 comments

I want to implement a custom annotation check function, check two related fields, based on the value of another field to determine whether this field should be checked as empty, but now I can not get the whole check object, so I can not achieve this custom check, I would like to ask, why the design is like this

image version jakarta.validation.validation-api 3.1.0

Sheldon66-Huang avatar Jul 19 '24 10:07 Sheldon66-Huang

A similar situation has been discussed in Hibernate discussion.

I personally think that determining the validation rules of another field based on the value of one field is not part of general technology, but more like a business logic or business rule. Then it is a good choice to present such business logic in the form of a method in the Bean class.

ximinghui avatar Oct 16 '24 09:10 ximinghui