Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSR 303 - Name of the annotated field in the custom validator

I have a question about custom annotations. More precisely, do I have access to the name of the annotated field inside the custom validator ? If yes, how do I access this?

Thanks

like image 319
TheRock3t Avatar asked Jan 22 '26 06:01

TheRock3t


1 Answers

You can access path via following exp

((ConstraintValidatorContextImpl) context).getConstraintViolationCreationContexts().get(0).getPath()
like image 87
reconnect Avatar answered Jan 25 '26 06:01

reconnect



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!