1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
15 namespace Castle
.Components
.Validator
20 /// Abstracts a JS validation library implementation.
21 /// Each implementation should map the calls to their
22 /// own approach to enforce validation.
24 public interface IBrowserValidationGenerator
27 /// Set that a field should only accept digits.
29 /// <param name="target">The target name (ie, a hint about the controller being validated)</param>
30 /// <param name="violationMessage">The violation message.</param>
31 void SetDigitsOnly(string target
, string violationMessage
);
34 /// Set that a field should only accept numbers.
36 /// <param name="target">The target name (ie, a hint about the controller being validated)</param>
37 /// <param name="violationMessage">The violation message.</param>
38 void SetNumberOnly(string target
, string violationMessage
);
41 /// Sets that a field is required.
43 /// <param name="target">The target name (ie, a hint about the controller being validated)</param>
44 /// <param name="violationMessage">The violation message.</param>
45 void SetAsRequired(string target
, string violationMessage
);
48 /// Sets that a field value must match the specified regular expression.
50 /// <param name="target">The target name (ie, a hint about the controller being validated)</param>
51 /// <param name="regExp">The reg exp.</param>
52 /// <param name="violationMessage">The violation message.</param>
53 void SetRegExp(string target
, string regExp
, string violationMessage
);
56 /// Sets that a field value must be a valid email address.
58 /// <param name="target">The target name (ie, a hint about the controller being validated)</param>
59 /// <param name="violationMessage">The violation message.</param>
60 void SetEmail(string target
, string violationMessage
);
63 /// Sets that field must have an exact lenght.
65 /// <param name="target">The target name (ie, a hint about the controller being validated)</param>
66 /// <param name="length">The length.</param>
67 void SetExactLength(string target
, int length
);
70 /// Sets that field must have an exact lenght.
72 /// <param name="target">The target name (ie, a hint about the controller being validated)</param>
73 /// <param name="length">The length.</param>
74 /// <param name="violationMessage">The violation message.</param>
75 void SetExactLength(string target
, int length
, string violationMessage
);
78 /// Sets that field must have an minimum lenght.
80 /// <param name="target">The target name (ie, a hint about the controller being validated)</param>
81 /// <param name="minLength">The minimum length.</param>
82 void SetMinLength(string target
, int minLength
);
85 /// Sets that field must have an minimum lenght.
87 /// <param name="target">The target name (ie, a hint about the controller being validated)</param>
88 /// <param name="minLength">The minimum length.</param>
89 /// <param name="violationMessage">The violation message.</param>
90 void SetMinLength(string target
, int minLength
, string violationMessage
);
93 /// Sets that field must have an maximum lenght.
95 /// <param name="target">The target name (ie, a hint about the controller being validated)</param>
96 /// <param name="maxLength">The maximum length.</param>
97 void SetMaxLength(string target
, int maxLength
);
100 /// Sets that field must have an maximum lenght.
102 /// <param name="target">The target name (ie, a hint about the controller being validated)</param>
103 /// <param name="maxLength">The maximum length.</param>
104 /// <param name="violationMessage">The violation message.</param>
105 void SetMaxLength(string target
, int maxLength
, string violationMessage
);
108 /// Sets that field must be between a length range.
110 /// <param name="target">The target name (ie, a hint about the controller being validated)</param>
111 /// <param name="minLength">The minimum length.</param>
112 /// <param name="maxLength">The maximum length.</param>
113 void SetLengthRange(string target
, int minLength
, int maxLength
);
116 /// Sets that field must be between a length range.
118 /// <param name="target">The target name (ie, a hint about the controller being validated)</param>
119 /// <param name="minLength">The minimum length.</param>
120 /// <param name="maxLength">The maximum length.</param>
121 /// <param name="violationMessage">The violation message.</param>
122 void SetLengthRange(string target
, int minLength
, int maxLength
, string violationMessage
);
125 /// Sets that field must be between a value range.
127 /// <param name="target">The target name (ie, a hint about the controller being validated)</param>
128 /// <param name="minValue">Minimum value.</param>
129 /// <param name="maxValue">Maximum value.</param>
130 /// <param name="violationMessage">The violation message.</param>
131 void SetValueRange(string target
, int minValue
, int maxValue
, string violationMessage
);
134 /// Sets that field must be between a value range.
136 /// <param name="target">The target name (ie, a hint about the controller being validated)</param>
137 /// <param name="minValue">Minimum value.</param>
138 /// <param name="maxValue">Maximum value.</param>
139 /// <param name="violationMessage">The violation message.</param>
140 void SetValueRange(string target
, decimal minValue
, decimal maxValue
, string violationMessage
);
143 /// Sets that field must be between a value range.
145 /// <param name="target">The target name (ie, a hint about the controller being validated)</param>
146 /// <param name="minValue">Minimum value.</param>
147 /// <param name="maxValue">Maximum value.</param>
148 /// <param name="violationMessage">The violation message.</param>
149 void SetValueRange(string target
, DateTime minValue
, DateTime maxValue
, string violationMessage
);
152 /// Sets that field must be between a value range.
154 /// <param name="target">The target name (ie, a hint about the controller being validated)</param>
155 /// <param name="minValue">Minimum value.</param>
156 /// <param name="maxValue">Maximum value.</param>
157 /// <param name="violationMessage">The violation message.</param>
158 void SetValueRange(string target
, string minValue
, string maxValue
, string violationMessage
);
161 /// Set that a field value must be the same as another field's value.
163 /// <param name="target">The target name (ie, a hint about the controller being validated)</param>
164 /// <param name="comparisonFieldName">The name of the field to compare with.</param>
165 /// <param name="violationMessage">The violation message.</param>
166 void SetAsSameAs(string target
, string comparisonFieldName
, string violationMessage
);
169 /// Set that a field value must _not_ be the same as another field's value.
171 /// <param name="target">The target name (ie, a hint about the controller being validated)</param>
172 /// <param name="comparisonFieldName">The name of the field to compare with.</param>
173 /// <param name="violationMessage">The violation message.</param>
174 void SetAsNotSameAs(string target
, string comparisonFieldName
, string violationMessage
);
177 /// Set that a field value must be a valid date.
179 /// <param name="target">The target name (ie, a hint about the controller being validated)</param>
180 /// <param name="violationMessage">The violation message.</param>
181 void SetDate(string target
, string violationMessage
);