Custom validations

More complex custom validations can be implemented using the @AssertTrue annotation. The following list an example method added to the User class:

    @AssertTrue(message = "Password fields don't match") 
private boolean isValid() {
return this.password.equals(this.password2);
}

@AssertTrue(message = "Password fields don't match") is the message to be shown if the validation fails.

Any complex validation logic with multiple fields can be implemented in these methods.