How to use default error messages

7 views
Skip to first unread message

Jim Richards

unread,
Jan 8, 2015, 1:03:11 AM1/8/15
to vt-middle...@googlegroups.com

Hi,

I've got my code working (in a Spring form validator) and when I get the default error message, I'm seeing

    TOO_SHORT:{minimumLength=8, maximumLength=16}

This is my code

 List<Rule> ruleList = new ArrayList<Rule>();

 
LengthRule lengthRule = new LengthRule(8, 16);
 ruleList
.add(lengthRule);

 
PasswordValidator validator = new PasswordValidator(ruleList);
 
PasswordData passwordData = new PasswordData(new Password(changePasswordForm.getPassword()));
 
RuleResult result = validator.validate(passwordData);

 
if (!result.isValid())
      errors
.rejectValue("password", "Password.invalid", validator.getMessages(result).toArray(), "");



Where the errors.rejectVaue is a Spring output with just

Password.invalid={0}

I thought it would look like

Password must be at least %1$s characters in length.


Thanks,
Jim

Reply all
Reply to author
Forward
0 new messages