|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ValidationConstraint.java | - | 100% | 100% | 100% |
|
1 |
// Copyright 2004, 2005 The Apache Software Foundation
|
|
2 |
//
|
|
3 |
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4 |
// you may not use this file except in compliance with the License.
|
|
5 |
// You may obtain a copy of the License at
|
|
6 |
//
|
|
7 |
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8 |
//
|
|
9 |
// Unless required by applicable law or agreed to in writing, software
|
|
10 |
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12 |
// See the License for the specific language governing permissions and
|
|
13 |
// limitations under the License.
|
|
14 |
|
|
15 |
package org.apache.tapestry.valid;
|
|
16 |
|
|
17 |
import org.apache.commons.lang.enum.Enum;
|
|
18 |
|
|
19 |
/**
|
|
20 |
* Defines an enumeration of different types of validation constraints that may be violated.
|
|
21 |
*
|
|
22 |
* @author Howard Lewis Ship
|
|
23 |
*/
|
|
24 |
|
|
25 |
public class ValidationConstraint extends Enum |
|
26 |
{ |
|
27 |
private static final long serialVersionUID = 371593028205311930L; |
|
28 |
|
|
29 |
/**
|
|
30 |
* Indicates that no value (or a value consisting only of white space) was provided for a field
|
|
31 |
* that requires a non-null value.
|
|
32 |
*/
|
|
33 |
|
|
34 |
public static final ValidationConstraint REQUIRED = new ValidationConstraint("REQUIRED"); |
|
35 |
|
|
36 |
/**
|
|
37 |
* Indicates that a non-null value was provided, but that (after removing leading and trailing
|
|
38 |
* whitespace), the value was not long enough.
|
|
39 |
*/
|
|
40 |
|
|
41 |
public static final ValidationConstraint MINIMUM_WIDTH = new ValidationConstraint( |
|
42 |
"MINUMUM_WIDTH");
|
|
43 |
|
|
44 |
/**
|
|
45 |
* Indicates a general error in converting a String into a Date.
|
|
46 |
*/
|
|
47 |
|
|
48 |
public static final ValidationConstraint DATE_FORMAT = new ValidationConstraint("DATE_FORMAT"); |
|
49 |
|
|
50 |
/**
|
|
51 |
* Indicates a general error in the format of a string that is to be interpreted as a email.
|
|
52 |
*/
|
|
53 |
|
|
54 |
public static final ValidationConstraint EMAIL_FORMAT = new ValidationConstraint("EMAIL_FORMAT"); |
|
55 |
|
|
56 |
/**
|
|
57 |
* Indicates a general error in the format of a string that is to be interpreted as a number.
|
|
58 |
*/
|
|
59 |
|
|
60 |
public static final ValidationConstraint NUMBER_FORMAT = new ValidationConstraint( |
|
61 |
"NUMBER_FORMAT");
|
|
62 |
|
|
63 |
/**
|
|
64 |
* Indicates that the value was too small (for a Date, too early).
|
|
65 |
*/
|
|
66 |
|
|
67 |
public static final ValidationConstraint TOO_SMALL = new ValidationConstraint("TOO_SMALL"); |
|
68 |
|
|
69 |
/**
|
|
70 |
* Indicates that the value was too large (for a Date, too late).
|
|
71 |
*/
|
|
72 |
|
|
73 |
public static final ValidationConstraint TOO_LARGE = new ValidationConstraint("TOO_LARGE"); |
|
74 |
|
|
75 |
/**
|
|
76 |
* Indicates an error in a string that does not fulfill a pattern.
|
|
77 |
*
|
|
78 |
* @since 3.0
|
|
79 |
*/
|
|
80 |
|
|
81 |
public static final ValidationConstraint PATTERN_MISMATCH = new ValidationConstraint( |
|
82 |
"PATTERN_MISMATCH");
|
|
83 |
|
|
84 |
/**
|
|
85 |
* Indicates a consistency error, usually between too different fields.
|
|
86 |
*
|
|
87 |
* @since 3.0
|
|
88 |
*/
|
|
89 |
|
|
90 |
public static final ValidationConstraint CONSISTENCY = new ValidationConstraint("CONSISTENCY"); |
|
91 |
|
|
92 |
/**
|
|
93 |
* Indicates that a URL is not of the correct format
|
|
94 |
*
|
|
95 |
* @since 3.0
|
|
96 |
*/
|
|
97 |
|
|
98 |
public static final ValidationConstraint URL_FORMAT = new ValidationConstraint("URL_FORMAT"); |
|
99 |
|
|
100 |
/**
|
|
101 |
* Indicates that the URL does not use one of the specified protocols
|
|
102 |
*
|
|
103 |
* @since 3.0
|
|
104 |
*/
|
|
105 |
|
|
106 |
public static final ValidationConstraint DISALLOWED_PROTOCOL = new ValidationConstraint( |
|
107 |
"DISALLOWED_PROTOCOL");
|
|
108 |
|
|
109 |
/**
|
|
110 |
* Protected constructor, which allows new constraints to be created as subclasses.
|
|
111 |
*/
|
|
112 |
|
|
113 | 11 |
protected ValidationConstraint(String name)
|
114 |
{ |
|
115 | 11 |
super(name);
|
116 |
} |
|
117 |
|
|
118 |
} |
|