1 package org.apache.turbine.services.intake.validator;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 /***
20 * Validator api.
21 *
22 * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
23 * @version $Id: Validator.java 264148 2005-08-29 14:21:04Z henning $
24 */
25 public interface Validator
26 {
27 /*** "flexible" Rule, used in DateFormat Validator */
28 String FLEXIBLE_RULE_NAME = "flexible";
29
30 /*** "format" Rule, used in DateFormat Validator */
31 String FORMAT_RULE_NAME = "format";
32
33 /*** "invalidNumber" Rule, used in the various Number Validators */
34 String INVALID_NUMBER_RULE_NAME = "invalidNumber";
35
36 /*** "mask" Rule, used in StringValidator */
37 String MASK_RULE_NAME = "mask";
38
39 /*** "maxLength" Rule, used in all validators */
40 String MAX_LENGTH_RULE_NAME = "maxLength";
41
42 /*** "maxValue" Rule, used in the various Number Validators */
43 String MAX_VALUE_RULE_NAME = "maxValue";
44
45 /*** "minLength" Rule, used in all validators */
46 String MIN_LENGTH_RULE_NAME = "minLength";
47
48 /*** "minValue" Rule, used in the various Number Validators */
49 String MIN_VALUE_RULE_NAME = "minValue";
50
51 /*** "required" Rule, used in all validators */
52 String REQUIRED_RULE_NAME = "required";
53
54 /***
55 * Determine whether a testValue meets the criteria specified
56 * in the constraints defined for this validator
57 *
58 * @param testValue a <code>String</code> to be tested
59 * @return true if valid, false otherwise
60 */
61 boolean isValid(String testValue);
62
63 /***
64 * Determine whether a testValue meets the criteria specified
65 * in the constraints defined for this validator
66 *
67 * @param testValue a <code>String</code> to be tested
68 * @exception ValidationException containing an error message if the
69 * testValue did not pass the validation tests.
70 */
71 void assertValidity(String testValue)
72 throws ValidationException;
73
74 /***
75 * Get the last error message resulting from invalid input.
76 *
77 * @return a <code>String</code> message, or the empty String "".
78 */
79 String getMessage();
80 }