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