// Create a test bean to validate against.
ValidateBean bean = new ValidateBean();
// Create a validator with the ValidateBean actions for the bean
// we're interested in.
Validator validator = new Validator(resources, "ValidateBean");
// Tell the validator which bean to validate against.
validator.addResource(Validator.BEAN_KEY, bean);
ValidatorResults results = null;
// Run the validation actions against the bean. Since all of the properties
// are null, we expect them all to error out except for street2, which has
// no validations (it's an optional property)
results = validator.validate();
printResults(bean, results, resources);
// Now set all the required properties, but make the age a non-integer.
// You'll notice that age will pass the required test, but fail the int
// test.
bean.setLastName("Tester");
bean.setFirstName("John");
bean.setStreet1("1 Test Street");
bean.setCity("Testville");
bean.setState("TE");
bean.setPostalCode("12345");
bean.setAge("Too Old");
results = validator.validate();
printResults(bean, results, resources);
// Now everything should pass.
bean.setAge("123");
results = validator.validate();
printResults(bean, results, resources);
} finally {
// Make sure we close the input stream if it was left open.
if (in != null) {