Skip to content

JSR 303: Bean Validation. Custom message from file

2013-08-24 14:30:39

    @NotNull(message = "{}")
    private Long id;

    @NotEmpty(message = "{}")
    private String name;

    @NotNull(message = "{postDto.desc.notNull}")
    @Size(min = 5, max=10, message = "{postDto.desc.size}")
    private String description;

src/java/resources/ should be pass should be pass
postDto.description.size=Description size must be between {min} and {max}
postDto.description.notNull=Description should be pass

If you want switch language, for example in test you can use:

    public void before() {
        Locale.setDefault(new Locale("en_us"));