O'Reilly logo

Java EE 7 Developer Handbook by Peter A. Pilgrim

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Constraint declarations

The bean validation specification has built-in constraints that cover the common constraints that a developer will encounter, albeit for basic validation.

Elements of a constraint

An annotated constraint in bean validation is declared through the key annotation @javax.validation.contraints.Constraint and three other properties.

Message property

The message property specifies the text and/or the Expression Language statement that the validation engine will use or evaluate when the constraint is violated.

String message() default  "{je7hb.beanvalidation.essentials.PostalCode.message}";

The annotation property message defines a default resource in order to look up the validation error message. For internationalization purposes, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required