0

My class:

public class Employee {

private String firstName;
private String lastName;
private Department department; 
//with getters and setters
}

My employee-validation.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<validation xmlns="http://www.springmodules.org/validation/bean" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://localhost:8080/BVF http://localhost:8080/BVF/validation.xsd">

<class name="Employee">
<validator class="EmployeeValidator"/>

<property name="firstName">
<not-blank message="FirstName cannot be left blank"/>
<length min="5" max="20" message="First Name Length cannot be less than 5 or more than 20"/>
</property>

<property name="lastName">
<not-blank message="LastName cannot be left balnk"/>
<length min="5" max="20" message="Last Name Length cannot be less than 5 or more than 20"/>
</property>

<property name="department.name">
<not-blank message="Name cannot be blank"/>
<length min="5" max="20" message="Name Length cannot be less than 5 or more than 20"/>
</property>

<property name="department.pinCode">
<not-blank message="Pin Code cannot be left blank"/> 
<regexp expression="^[A-Z\d{1}]\d{4}[\s\-]*\d*$" message="PinCode is invalid"/> 
<length min="5" max="10" message="Pincode length should be between 5 and 10"/>

</property>

</class>

</validation>

can someone tell me how i can access the elements of department object, i.e. this part

<property name="department.pinCode">

1 Answers1

0

i have found the solution, which is to use the cascade attribute.