01: package org.jreform.criteria;
02:
03: /**
04: * Checks that the value conforms to a valid Canadian postcode.
05: *
06: * @author armandino (at) gmail.com
07: */
08: public final class PostcodeCA extends Regex {
09: // NOTE: single space required
10: private static final String REGEX = "^[ABCEGHJKLMNPRSTVXYabceghjklmnprstvxy]\\d"
11: + "[ABCEGHJKLMNPRSTVWXYZabceghjklmnprstvwxyz]\\s"
12: + "\\d[ABCEGHJKLMNPRSTVWXYZabceghjklmnprstvwxyz]\\d$";
13:
14: PostcodeCA() {
15: super (REGEX);
16: }
17:
18: protected String generateErrorMessage() {
19: return "Please enter a valid postcode";
20: }
21:
22: }
|