[hibernate-issues] [Hibernate-JIRA] Commented: (HV-389) Support conditional validation at property level
Hardy Ferentschik (JIRA)
noreply at atlassian.com
Thu Oct 14 05:04:48 EDT 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/HV-389?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=38736#action_38736 ]
Hardy Ferentschik commented on HV-389:
--------------------------------------
To do this we would have to introduce for each constraint defined in the spec a new Hibernate specific constraint with the additional parameter. I don't think this is a good idea. I think being able to use @ScriptAssert on property level (HV-388) is a much better solution and will also cover this case.
> Support conditional validation at property level
> ------------------------------------------------
>
> Key: HV-389
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-389
> Project: Hibernate Validator
> Issue Type: New Feature
> Components: engine
> Affects Versions: 4.1.0.Final
> Reporter: jason shi
> Assignee: Hardy Ferentschik
>
> In Oval, there is a "when" attribute in each ConstrainsChecker,which can be used for conditional check.
> In the following example fieldB must not be null only if fieldA is not null as well. With the prefix groovy: it is indicated that the formula is expressed in the Groovy language.
> {code}
> public class BusinessObject
> {
> private String fieldA;
> @NotNull(when = "groovy:_this.fieldA != null")
> private String fieldB;
> }
> {code}
> Although we can use ScriptAssert as a work-around, but ScriptAssert can't be used at property level validation, and the "when" attribute make the validation logical more clearly.
> In UI layer validation, this feature is very important in instant UI validation.
> The hibernate validator should have the ability to pass a ValueContext to the Validator,then we can write a custom Contrains to implement this feature.
--
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