From the course: Java EE: Bean Validation

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Cross-parameter validation implementation

Cross-parameter validation implementation

From the course: Java EE: Bean Validation

Start my 1-month free trial

Cross-parameter validation implementation

- [Narrator] Cross-parameter constraints validate parameters to methods and constructors that are logically connected. Just as cross-field constraints validate the cross-fields, cross-parameter constraints validate the cross-parameters. A cross-parameter constraint is set up in exactly the same way as we have been setting up custom constraints. A cross-parameter constraint is setup in the same way as the custom constraints we have been creating during this course. So you create an annotation for the validation constraint and then a separate class for the validation logic. The only difference is the validated class must be annotated with a supported validation target annotation. This enables enables validation across parameters and distinguishes it from return value validation. This is because both return validation and cross parameter validation constraints are placed on the method. Okay, let's have a look at some code examples. Here's the client Bean and here is the constructor. As…

Contents