Java Reference
In-Depth Information
Class<? extends Payload>[] payload() default {};
@Target({ElementType.METHOD,
ElementType.FIELD,
ElementType.ANNOTATION_TYPE,
ElementType.CONSTRUCTOR,
ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@interface List {
Email[] value();
}
}
This custom constraint can then be applied to an attribute.
...
@Email
protected String email;
...
Customizing Validator Messages
Bean Validation includes a resource bundle of default messages for the built-in con-
straints. These messages can be customized, and localized for non-English speaking loc-
ales.
The
ValidationMessages
Resource Bundle
The
Validationmessages
resource bundle and the locale variants of this resource
bundle contain strings that override the default validation messages. The
Valida-
tionMessages
resource bundle is typically a properties file,
ValidationMes-
sages.properties
, in the default package of an application.
Localizing Validation Messages
Locale variants of
ValidationMessages.properties
are added by appending an
underscore and the locale prefix to the base name of the file. For example, the Spanish
locale variant resource bundle would be
ValidationMessages_es.properties
.