![Mastering Spring 5.0](https://wfqqreader-1252317822.image.myqcloud.com/cover/64/36701064/b_36701064.jpg)
上QQ阅读APP看书,第一时间看更新
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.