You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@cocoon.apache.org by do...@cocoon.apache.org on 2004/07/19 20:19:13 UTC
[Cocoon Wiki] Updated: WoodyValidationRuleReference
Date: 2004-07-19T11:19:13
Editor: StephanNiedermeier <no...@nono.no>
Wiki: Cocoon Wiki
Page: WoodyValidationRuleReference
URL: http://wiki.apache.org/cocoon/WoodyValidationRuleReference
no comment
Change Log:
------------------------------------------------------------------------------
@@ -2,14 +2,14 @@
For each validation rule, the failmessage (i.e. the message displayed to the user in case the validation failed) can be overridden by specifying a child '''wd:failmessage''' element inside the validation rule element. The failmessage can contain mixed content. Example:
-{{{
-<wd:datatype base="string">
- <wd:validation>
- <wd:email>
- <wd:failmessage>Not a valid email address!</wd:failmessage>
- </wd:email>
- </wd:validation>
-</wd:datatype>
+{{{
+<wd:datatype base="string">
+ <wd:validation>
+ <wd:email>
+ <wd:failmessage>Not a valid email address!</wd:failmessage>
+ </wd:email>
+ </wd:validation>
+</wd:datatype>
}}}
To provide locale-dependent messages, use i18n tags in combination with the I18NTransformer.
@@ -18,82 +18,82 @@
= Summary =
-||'''Validator'''||||Allowed datatypes
-||assert||all datatypes
-||email||string
-||length||string
-||mod10||string
-||range||integer, long, decimal
-||regexp||string
-||value-count||all datatypes as part of multivaluefield
+||'''Validator'''||||Allowed datatypes||
+||assert||all datatypes||
+||email||string||
+||length||string||
+||mod10||string||
+||range||integer, long, decimal||
+||regexp||string||
+||value-count||all datatypes as part of multivaluefield||
= Description =
== assert ==
Evaluates the expression specified in the "test" attribute. This expression should have a boolean result, it should evaluate to either true or false. Example: Suppose there are 2 fields widgets {{{password}}} and {{{confirmPassword}}}. We can use assert inside {{{confirmPassword}}} to check if is equals to {{{password}}} widget:
-{{{
-<wd:assert test="password = confirmPassword">
- <wd:failmessage>The two passwords are not equal.</wd:failmessage>
-</wd:assert>
+{{{
+<wd:assert test="password = confirmPassword">
+ <wd:failmessage>The two passwords are not equal.</wd:failmessage>
+</wd:assert>
}}}
== email ==
Checks that a value is a valid email address. Example:
-{{{
-<wd:email/>
+{{{
+<wd:email/>
}}}
== length ==
Checks the length of strings. This validation rule can take 3 attributes: min, max and exact. You can use either of these three separately or min and max together. The values of these attributes are expressions. Example:
-{{{
-<wd:length min="2" max="4"/>
-
-Another example:
-
-<wd:length exact="2*2">
- <wd:failmessage>Must be 4 characters long!</wd:failmessage>
-</wd:length>
+{{{
+<wd:length min="2" max="4"/>
+
+Another example:
+
+<wd:length exact="2*2">
+ <wd:failmessage>Must be 4 characters long!</wd:failmessage>
+</wd:length>
}}}
== mod10 ==
Uses the "mod10" algorithm used to check the validity of credit card numbers such as VISA. This validation rule does not require any additional attributes. Example:
-{{{
-<wd:mod10>
- <wd:failmessage>Invalid credit card number.</wd:failmessage>
-</wd:mod10>
+{{{
+<wd:mod10>
+ <wd:failmessage>Invalid credit card number.</wd:failmessage>
+</wd:mod10>
}}}
== range ==
Checks the numeric range. This validation rule can take 3 attributes: min, max and exact. You can use either of these three separately or min and max together. The values of these attributes are expressions. Example:
-{{{
-<wd:range min="2" max="4"/>
-
-Another example:
-
-<wd:range exact="2*2"/>
+{{{
+<wd:range min="2" max="4"/>
+
+Another example:
+
+<wd:range exact="2*2"/>
}}}
== regexp ==
Checks that a string matches a regular expression. It requires a "pattern" attribute specifying the regexp. The regular expression library used is Jakarta ORO, see [http://jakarta.apache.org/oro/api/org/apache/oro/text/regex/package-summary.html ORO API docs] for some information. Example:
-{{{
-<wd:regexp pattern="[a-z]{3,5}">
- <wd:failmessage>Invalid code!</wd:failmessage>
-</wd:regexp>
+{{{
+<wd:regexp pattern="[a-z]{3,5}">
+ <wd:failmessage>Invalid code!</wd:failmessage>
+</wd:regexp>
}}}
== value-count ==
Checks the number of items selected in a multivaluefield. Again works with min, max and exact attributes. Example:
-{{{
-<wd:value-count min="2" max="4"/>
-
-Another example:
-
-<wd:value-count exact="2"/>
+{{{
+<wd:value-count min="2" max="4"/>
+
+Another example:
+
+<wd:value-count exact="2"/>
}}}