org.openmrs.validator
Class PersonNameValidator

java.lang.Object
  extended by org.openmrs.validator.PersonNameValidator
All Implemented Interfaces:
org.springframework.validation.Validator

@Handler(supports=PersonName.class,
         order=50)
public class PersonNameValidator
extends java.lang.Object
implements org.springframework.validation.Validator

This class validates a PersonName object.

Since:
1.7

Constructor Summary
PersonNameValidator()
           
 
Method Summary
 boolean supports(java.lang.Class c)
           
 void validate(java.lang.Object object, org.springframework.validation.Errors errors)
          Checks whether person name has all required values, and whether values are proper length
 void validatePersonName(PersonName personName, org.springframework.validation.Errors errors, boolean arrayInd, boolean testInd)
          Checks that the given PersonName is valid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersonNameValidator

public PersonNameValidator()
Method Detail

supports

public boolean supports(java.lang.Class c)
Specified by:
supports in interface org.springframework.validation.Validator
See Also:
Validator.supports(java.lang.Class)

validate

public void validate(java.lang.Object object,
                     org.springframework.validation.Errors errors)
Checks whether person name has all required values, and whether values are proper length

Specified by:
validate in interface org.springframework.validation.Validator
Parameters:
personName -
errors -
Expected behavior:
fail validation if PersonName object is null

validatePersonName

public void validatePersonName(PersonName personName,
                               org.springframework.validation.Errors errors,
                               boolean arrayInd,
                               boolean testInd)
Checks that the given PersonName is valid

Parameters:
personName - the PersonName to validate
errors -
arrayInd - indicates whether or not a names[0] array needs to be prepended to field
Expected behavior:
fail validation if PersonName object is null, fail validation if PersonName.givenName is null, fail validation if PersonName.givenName is empty, fail validation if PersonName.givenName is just spaces, fail validation if PersonName.givenName is spaces surrounded by quotation marks, pass validation if PersonName.givenName is not blank, fail validation if PersonName.familyName is null, fail validation if PersonName.familyName is empty, fail validation if PersonName.familyName is just spaces, fail validation if PersonName.familyName is spaces surrounded by quotation marks, pass validation if PersonName.familyName is not blank, fail validation if PersonName.prefix is too long, pass validation if PersonName.prefix is exactly max length, pass validation if PersonName.prefix is less than maximum field length, fail validation if PersonName.givenName is too long, pass validation if PersonName.givenName is exactly max length, pass validation if PersonName.givenName is less than maximum field length, fail validation if PersonName.middleName is too long, pass validation if PersonName.middleName is exactly max length, pass validation if PersonName.middleName is less than maximum field length, fail validation if PersonName.familyNamePrefix is too long, pass validation if PersonName.familyNamePrefix is exactly max length, pass validation if PersonName.familyNamePrefix is less than maximum field length, fail validation if PersonName.familyName is too long, pass validation if PersonName.familyName is exactly max length, pass validation if PersonName.familyName is less than maximum field length, fail validation if PersonName.familyName2 is too long, pass validation if PersonName.familyName2 is exactly max length, pass validation if PersonName.familyName2 is less than maximum field length, fail validation if PersonName.familyNameSuffix is too long, pass validation if PersonName.familyNameSuffix is exactly max length, pass validation if PersonName.familyNameSuffix is less than maximum field length, fail validation if PersonName.degree is too long, pass validation if PersonName.degree is exactly max length, pass validation if PersonName.degree is less than maximum field length

OpenMRS-1.7.x

Generated Apr 27 2012 10:06 PM. NOTE - these libraries are in active development and subject to change