Hi All,
I am testing bean validation using XMl and here is code from my
Code:
validation.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<validation-config
xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configurationvalidation-configuration-1.0.xsd">
<constraint-mapping>org/demo/actions/modeldriven.xml</constraint-mapping>
</validation-config>
and modeldriven.xml have following data
Code:
<constraint-mappings
xmlns="http://jboss.org/xml/ns/javax/validation/mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd">
<bean class="com.raisonne.bd.dto.donor.DonorProfileDTOModel" ignore-annotations="true">
<field name="name">
<constraint annotation=" javax.validation.constraints.NotNull"/>
</field>
<field name="dateOfBirth">
<constraint annotation=" org.hibernate.validator.constraints.NotBlank"/>
</field>
<field name="gender">
<constraint annotation=" org.hibernate.validator.constraints.NotBlank"/>
</field>
<field name="weight">
<constraint annotation="javax.validation.constraints.NotNull"/>
<constraint annotation="javax.validation.constraints.Min">
<element name="value">45</element>
</constraint>
</field>
<field name="mobile">
<constraint annotation=" javax.validation.constraints.Size"/>
</field>
</bean>
</constraint-mappings>
I tried every way, but seems like hibernate validator is not picking up modeldriven.xml.I tested with fully qualified class name like
Code:
<bean class="com.raisonne.bd.dto.donor.DonorProfileDTOModel" ignore-annotations="true">
and even with setting default package name like
Code:
<default-package>com.raisonne.bd.dto.donor</default-package>
<bean class="DonorProfileDTOModel" ignore-annotations="true">
This is what i am getting in server console
Code:
INFO (org.hibernate.validator.internal.xml.ValidationXmlParser:191) - HV000007: META-INF/validation.xml found. Parsing XML based configuration.
Not sure why it is not including modeldriven.xml file
Seems like nothing is working.
Can any one point me where i am doing wrong..