Reputation: 8825
`this is my sample.xml files
<field name="userName">
<constraint annotation="org.hibernate.validator.constraints.NotBlank"/>
<constraint annotation="javax.validation.constraints.Size">
<element name ="min">1</element>
<element name ="max">20</element>
</constraint>
</field>`
if there is a way to configure the hibernate validator so that "Size" validations runs only if the NotBlank valditons falis and show validations messages only for the Size not correct. here is the modifed xml
<bean class="User">
<field name="systemCode">
<constraint annotation="org.hibernate.validator.constraints.NotBlank">
<groups>
<value>UserNameNotBlank</value>
</groups>
</constraint>
<constraint annotation="javax.validation.constraints.Size">
<groups>
<value>UserNameSize</value>
</groups>
<element name="min">1</element>
<element name="max">4</element>
</constraint>
</field>
</bean>
what are the next steps the interfaces had been created is it possible to performing ordering on the field level or is it possible only on method level. Note : please give the reference link where xml based configurations are there.
Upvotes: 2
Views: 1679
Reputation: 19129
There is no order for constraint validation unless a group sequence is used. The spec says:
By default, constraints are evaluated in no particular order regardless of which groups they belong to...
And a little further on
To implement such ordering, a group can be defined as a sequence of other groups...
Upvotes: 2