01: package org.jreform.criteria;
02:
03: /**
04: * Checks that value is not greater than the specified maximum.
05: *
06: * @author armandino (at) gmail.com
07: */
08: public final class MaxLength extends AbstractCriterion<String> {
09: private int maxLength;
10:
11: MaxLength(int maxLength) {
12: this .maxLength = maxLength;
13: }
14:
15: protected boolean verify(String value) {
16: return value.length() <= maxLength;
17: }
18:
19: protected String generateErrorMessage() {
20: return "The value must not be greater than " + maxLength
21: + " characters long";
22: }
23:
24: }
|