Reputation: 8950
I've got the following annotation:
@NotEmpty
@Documented
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = SupportedVideoUrlValidator.class)
public @interface SupportedVideoUrl {
String message() default "{cast.submission.error.video}";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
String value() default "";
}
It works OK except the i18n part. The post-validation error message is displayed as is. I do not know how to handle this...
If you have any ideas, thanks in advance for your help!
Rolf
Upvotes: 2
Views: 1708
Reputation: 4371
Assuming you are using JSR-303 annontations, put a file ValidationMessages.properties
at the root of your classpath containing:
cast.submission.error.video=Video URL is not supported.
this file is loaded as a ResourceBundle so if you need message for a different language add the language suffix to the file (eg ValidationMessages_de.properties
for german translations).
Upvotes: 1