Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Bean Validation: customize Error Messages

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                                                    Home


This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here

Share the post

Bean Validation: customize Error Messages

×

Subscribe to Java Tutorial : Blog To Learn Java Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×