Bean validation annotations provide default Error Messages.
For example, following snippet specify, property ‘name’ must have minium 5 characters.
@Size(min=5)
private String name;
In case of name with below 5 characters in length, you will get following default Message.
name,size must be between 5 and 2147483647
There are two ways to add custom messages.
a. Using the ‘message’ attribute of the constraint.
b. Globally configure validation error messages in a property file
Previous Next HomeThis post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here