Skip to content

Commit

Permalink
TRUNK-3820: PersonNameValidator appears to be validating voided perso…
Browse files Browse the repository at this point in the history
…n names
  • Loading branch information
rkorytkowski committed Dec 10, 2012
1 parent 4235333 commit 81d0750
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public boolean supports(Class c) {
* @param personName
* @param errors
* @should fail validation if PersonName object is null
* @should pass validation if name is invalid but voided
*/
public void validate(Object object, Errors errors) {
if (log.isDebugEnabled())
Expand All @@ -55,7 +56,7 @@ public void validate(Object object, Errors errors) {
// Validate that the person name object is not null
if (personName == null)
errors.reject("error.name");
if (!errors.hasErrors())
if (!errors.hasErrors() && !personName.isVoided())
validatePersonName(personName, errors, true, false);
}
catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,4 +656,20 @@ public void validatePersonName_shouldNotValidateAgainstRegexForBlankNames() thro
new PersonNameValidator().validatePersonName(personName, errors, false, true);
Assert.assertFalse(errors.hasErrors());
}

/**
* @see PersonNameValidator#validate(Object,Errors)
* @verifies pass validation if name is invalid but voided
*/
@Test
public void validate_shouldPassValidationIfNameIsInvalidButVoided() throws Exception {
PersonName personName = new PersonName();
personName.setVoided(true);
personName.setFamilyName2("34dfgd"); //invalid familyName2

Errors errors = new BindException(personName, "familyName2");
new PersonNameValidator().validate(personName, errors);

Assert.assertFalse(errors.hasErrors());
}
}

0 comments on commit 81d0750

Please sign in to comment.