This issue can't be edited
Because it belongs to an archived project. Jira admins can restore projects from the archive.
Offer possibility to skip validation on empty or null
Description
Environment
Activity
Emmanuel Bernard March 16, 2012 at 3:12 PM
If we can come up with a generic way to defined when this needs to be skipped, we can solve your use case Geert.
1. we need a mechanism
2. we need to see how to configure it
per constraint and hardwired
per constraint but customizable
per type
If we do per constraint and hard wired, people will need to create specific annotations for their constraints accepting that "\t" is "null".
GeertM March 14, 2012 at 1:29 PM
I will need to catch up on this issue, but I would already like to point out something before making more concrete comments.. have you also considered Strings that only contain blanks? Like " " or " \t " etc..
Hardy Ferentschik January 27, 2012 at 1:39 PM
Wouldn't the composed constraint approach require the boolean composition feature?
Now, if the value is null it will pass the @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.
Emmanuel Bernard January 26, 2012 at 5:30 PM
The goal of this issue is to let people declaratively say that a constraint should not be executed if the value is null or empty. This avoids the famous
I now realize that Peter's suggestion would raise an ConstraintViolation if the constraint is applied on a null value which is not what I had in mind. We could work around that with a property on @RepostAsSingleViolation or as another explicit annotation @IgnoreConstraintOnFailingSubConstraints (or something like that).
Hardy Ferentschik January 10, 2012 at 7:08 PM
Is Peter's suggestion not just an extension of which makes it configurable whether validation of a composed constraint stops on the first validation error. I don't really see the connection to this issue and what exactly this issue is about.
https://issues.apache.org/jira/browse/EXTVAL-74