Individually, each field is valid. But from a cross-field point of view, the user isn't taking the submission process seriously.
Goal: You will use cross-field validation to ensure the user isn't entering garbage data.
The following code rejects a field and adds an error to the
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:
- reject the
lastNameif it happens to equal the
- Leave the error code empty
- Display the error message:
please enter valid data.