[hibernate-issues] [Hibernate-JIRA] Issue Comment Edited: (BVAL-202) Apply constraints on the elements of an iterator
Emmanuel Bernard (JIRA)
noreply at atlassian.com
Mon Mar 15 11:38:47 EDT 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/BVAL-202?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=35832#action_35832 ]
Emmanuel Bernard edited comment on BVAL-202 at 3/15/10 10:38 AM:
-----------------------------------------------------------------
Solution #4
add a new OnElements subannotation. This annotation should contain all the attribute of its mother constraint annotation. .List should probably contains this annotation too.
[code]
@NotNull
@Size(max=30)
@Size.OnElements(max=50)
@Email.OnElements
Collection<String> emails;
[/code]
where
public @interface Size {
String message() default {...};
int min default 0;
...
@interface OnElements {
String message() default {...};
int min default 0;
}
@interface List {
Size[] value();
@interface OnElements {
Size[] value();
}
}
advanced example
@Size.List.OnElements( {
@Size(max=30),
@Size(max=40, groups=Admin.class)
})
The drawback of this method is that:
- it requires to change existing applications
- it make creating a constraint pretty complex
was (Author: emmanuel):
Solution #4
add a new OnElements subannotation. This annotation should contain all the attribute of its mother constraint annotation. .List should probably contains this annotation too.
<code>
@NotNull
@Size(max=30)
@Size.OnElements(max=50)
@Email.OnElements
Collection<String> emails;
</code>
where
public @interface Size {
String message() default {...};
int min default 0;
...
@interface OnElements {
String message() default {...};
int min default 0;
}
@interface List {
Size[] value();
@interface OnElements {
Size[] value();
}
}
advanced example
@Size.List.OnElements( {
@Size(max=30),
@Size(max=40, groups=Admin.class)
})
The drawback of this method is that:
- it requires to change existing applications
- it make creating a constraint pretty complex
> Apply constraints on the elements of an iterator
> ------------------------------------------------
>
> Key: BVAL-202
> URL: http://opensource.atlassian.com/projects/hibernate/browse/BVAL-202
> Project: Bean Validation
> 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