[hibernate-issues] [Hibernate-JIRA] Commented: (BVAL-220) Offer possibiltiy to skip validation on empty or null

Hardy Ferentschik (JIRA) noreply at atlassian.com
Fri Jan 27 06:40:10 EST 2012


    [ http://opensource.atlassian.com/projects/hibernate/browse/BVAL-220?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45276#comment-45276 ] 

Hardy Ferentschik commented on BVAL-220:
----------------------------------------

Wouldn't the composed constraint approach require the boolean composition feature?
{code}
@ConstraintComposition(OR)
@ReportAsSingleViolation
@Null 
@Constraint(validatedBy=MyValidator)
public @interface MyConstraint {}
{code}
Now, if the value is null it will pass the _ at Null_ constraint and due to the _OR_ the whole constraint will pass. If the value is not null _MyConstraint_ will have to pass.

However, there is of course the issue of multiple constraints in a composed constraint and that there is no way to define an order.

Also, if I understand the problem correctly, it is very much driven by string validation driven eg by some web framework. Would the intend not be to define the "skip validation on empty" only once and have it applied to all string based constraints? With the composing constraint approach I have to wrap each single constraint in question.

> Offer possibiltiy to skip validation on empty or null
> -----------------------------------------------------
>
>                 Key: BVAL-220
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/BVAL-220
>             Project: Bean Validation
>          Issue Type: New Feature
>          Components: spec-general
>            Reporter: Emmanuel Bernard
>
> https://issues.apache.org/jira/browse/EXTVAL-74

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list