[hibernate-issues] [Hibernate-JIRA] Commented: (HV-295) Apply constraints on the elements of an iterator

Emmanuel Bernard (JIRA) noreply at atlassian.com
Mon Mar 15 11:24:48 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HV-295?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=35827#action_35827 ] 

Emmanuel Bernard commented on HV-295:
-------------------------------------

Use a specific group as a marker to define that a constraint should be applied on the elements

@NotNull
@Size(max=30)
@Size(max=50, groups=OnElements.class)
@Email(groups=OnElements.class)
Collection<String> emails;

@NotNull and @Size(30) are applied on the collection and @Size(50) and @Email are applied on the elements of the collection

This solution reads extremely well but is kind of a hack of groups as this special group does not convey the semantic of groups.

An alternative approach is to use Payloads

@NotNull
@Size(max=30)
@Size(max=50, payload=OnElements.class)
@Email(payload=OnElements.class)
Collection<String> emails;

but I am reluctant to use payload for some core behaviors of Bean Validation

> Apply constraints on the elements of an iterator
> ------------------------------------------------
>
>                 Key: HV-295
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-295
>             Project: Hibernate Validator
>          Issue Type: New Feature
>          Components: spec-general
>            Reporter: Emmanuel Bernard
>            Assignee: Hardy Ferentschik
>
> The use case is the ability to ask a constraint to be applied, not on the annotated element itself but on the elements contained by the annotated element (typically an Iterator). Hardy and I have been discussing various options. I will list them in various comments

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list