Thanks to this question, I think I understand how validation is working.
As for JPA, here we have a specification called JSR-303 explaining how Bean Validation should work and then we are using implementations like the commonly used Hibernate Validator or Apache BVal also.
I am struggling about using @Valid
in some part of my code. I am not using @Validated
because I do not need group validation.
You can find an example of a demo project here
In PropertyExample
class, you can see I marked my class for bean validation to happen.
When using @Validated
, everything work as expected since I am violating a constraint in my application.yml
file.
When using @Valid
over @Validated
, it seems nothing happens. I do not understand why.
I saw too that those annotations could be used on ElementType.PARAMETER
but when I am using using them during constructor initialisation, validation doesn't seem to trigger either.
Explanations on how to used those annotations (especially the @Valid
) would be greatly appreciated.