Glapa
Glapa

Reputation: 800

Hibernate validation property path for validation List with JSR-308

I have following code:

public class ReferEmailForm {
    @Valid
    @NotEmpty
    private Set<@TypedEmail String> emails;

    ...
}

For some reason error from @TypedEmail in BindingResult is notified as attached to emails[] field. Is there any option to override this name? I need this to be able to use <form:errors path="emails" /> in jsp. Current solution don't generate error message on form unfortunately.

Upvotes: 1

Views: 428

Answers (1)

Glapa
Glapa

Reputation: 800

After searching for answer everywhere I just noticed how stupid mistake I did. Hibernate is resolving variable name as emails[] because Set do not have index based access. After changing type to List it returns emails[0] which is way better.

Upvotes: 1

Related Questions