Jersey/JAX-RS : How to cascade beans-validation recursively with @Valid automatically? Jersey/JAX-RS : How to cascade beans-validation recursively with @Valid automatically? java java

Jersey/JAX-RS : How to cascade beans-validation recursively with @Valid automatically?


Actually, according to the specification, adding @Valid is exactly for this usecase. From the JSR 303 specification:

In addition to supporting instance validation, validation of graphs of object is also supported. The result of a graph validation is returned as a unified set of constraint violations. Consider the situation where bean X contains a field of type Y. By annotating field Y with the @Valid annotation, the Validator will validate Y (and its properties) when X is validated.

...

The @Valid annotation is applied recursively