* Performs validations for the given account. The main validation
* is against the account number, which can be changed but not to
* a number that's already in use by another account.
*/
public void validate(Object target, Errors errors) {
Account account = (Account) target;
if (StringUtils.isNotEmpty(account.getNumber())) {
Account existingAccount = accountManager.findAccount(account.getNumber());
if (existingAccount != null) {
if (! account.getEntityId().equals(existingAccount.getEntityId())) {
errors.rejectValue("number", "account.number.inuse");
}
}
}
// ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "errors.required", new String[]{"name"});