Spring Boot Bootcamp – Workbooks and Challenges
)}

Workbook 3.2

Individually, each field is valid. But from a cross-field point of view, the user isn't taking the submission process seriously.

Screen Shot 2022-05-21 at 7.32.27 PM.png

Goal: You will use cross-field validation to ensure the user isn't entering garbage data.

Task 1

The following code rejects a field and adds an error to the BindingResult.

bindingResult.rejectValue(arg1, arg2, arg3): // Argument 1: The field value you wish to reject. // Argument 2: Error Code // Argument 3: Error message.

Using this information:

  1. reject the lastName if it happens to equal the firstName.
  2. Leave the error code empty "".
  3. Display the error message: please enter valid data.

Screen Shot 2022-05-21 at 7.53.42 PM.png

Good Luck!

Feedback Summary
5.0
3 students
5

100%
4

0%
3

0%
2

0%
1

0%
Written Reviews
There are no written reviews yet.