henning 01/06/13 05:35:51
Modified: xdocs/services intake-service.xml
Log:
After fiddling for quite a while with intake and getting somehow
frustrated, this is at least a partial update to the intake service
documentation which makes the scarab examples working again (as far as
I can see, required-message is gone and replaced by the "required"
rule).
I also added a section about the different rule types without
diverting into any other projects, business objects or stuff but just
describing what the rules do. A section like this would've me saved
most of yesterday in tinkering to get "minLength" working.
Revision Changes Path
1.8 +64 -11 jakarta-turbine/xdocs/services/intake-service.xml
Index: intake-service.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine/xdocs/services/intake-service.xml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- intake-service.xml 2001/06/01 17:10:34 1.7
+++ intake-service.xml 2001/06/13 12:35:48 1.8
@@ -6,6 +6,7 @@
<title>Turbine Services - Intake Service</title>
<author email="[EMAIL PROTECTED]">John McNally</author>
<author email="[EMAIL PROTECTED]">Jon S. Stevens</author>
+ <author email="[EMAIL PROTECTED]">Henning P. Schmiedehausen</author>
</properties>
<body>
@@ -127,20 +128,20 @@
mapToObject="om.AttributeValue">
<field name="Value" key="val" type="String">
<rule name="maxLength" value="255">Value length cannot be > 255</rule>
- <required-message>This module requires data for this
+ <rule name="required" value="true">This module requires data for this
attribute.
- </required-message>
+ </rule>
</field>
<field name="Url" key="url" type="String" mapToProperty="Value">
<rule name="maxLength" value="255">Url length cannot be > 255</rule>
<rule name="mask" value="^$|http.+">Please enter an url starting with
"http"</rule>
- <required-message>This module requires a valid url.</required-message>
+ <rule name="required" value="true">This module requires a valid url.</rule>
</field>
<field name="OptionId" key="optionid" type="NumberKey">
<rule name="mask" value="^$|[0-9]+">Please select a valid choice</rule>
- <required-message>This module requires that you select an option
+ <rule name="required" value="true">This module requires that you select an
option
for this attribute.
- </required-message>
+ </rule>
</field>
</group>
@@ -188,10 +189,62 @@
Email, Url, or Date, will be added that will add functionality that is
difficult or not possible with a simple regex mask.
</p>
+</section>
+
+<section name="Field Rules">
+
<p>
The field can define rule elements. The basic fields include rules for
minimum and maximum, lengths and values, as well as a regex mask.
</p>
+<p>The basic validator can do four different checks:</p>
+
+<p>required - Must this element be present or not? If it is not
+required, some of the following checks, namely the minLength may not
+work as expected.</p>
+<source><![CDATA[
+ <rule type="required" value="true">This field must be present</rule>
+]]></source>
+
+<p> minLength - The minium length of the input string. Note that one of the
+ most obvious uses of this check, namely that the length is at least 1
+ character should not be done here but with "required" above. The following
+ example does <b>not</b> work!</p>
+
+<source><![CDATA[
+ <rule type="minLength" value="1">This form field must be filled out</rule>
+]]></source>
+
+ <p>If the field is not required, then the following checks are (of course)
+ not done if the field is not present at all! So the check above is always
+ true unless there is also a "required" rule but then you don't need this
+ check no longer. The following example is much better:</p>
+
+<source><![CDATA[
+ <rule type="required" value="true">This field must be present</rule>
+ <rule type="minLength" value="8">This field must have at least eight
characters!</rule>
+]]></source>
+
+ <p>maxLength - The maximum length of the input string. This is pretty
+ straightforward. If the field is longer than this rule, you get an
+ error.</p>
+<source><![CDATA[
+ <rule type="maxLength" value="64">This field must have 64 or less
characters!</rule>
+]]></source>
+
+ <p>mask - A regular expression mask which the input field must fit. This
+ is very useful if you enter some formatted data (e.g. a date) into a
+ string field and want to rule out some of the basic errors. The
+ regular expressions are taken from the <A
+ HREF="http://jakarta.apache.org/regexp/">Jakarta Regexp package</A>
+ and are described in the javadocs <A
+ HREF="http://jakarta.apache.org/regexp/apidocs/org/apache/regexp/RE.html">
+ here</A>.</p>
+<source><![CDATA[
+<rule type="mask" value="\d\d?\.\d\d?\.\d\d\d?\d?">The date format is
invalid!</rule>
+]]></source>
+ <p>Note that you can have only one mask rule per field. It is not
+ possible to use multiple masks for a single field.</p>
</section>
@@ -494,14 +547,14 @@
<source><![CDATA[
<field name="Value" key="val" type="String">
<rule name="maxLength" value="255">Value length cannot be > 255</rule>
- <required-message>This module requires data for this
+ <rule name="required" value="true">This module requires data for this
attribute.
- </required-message>
+ </rule>
</field>
<field name="Url" key="url" type="String" mapToProperty="Value">
<rule name="maxLength" value="255">Url length cannot be > 255</rule>
<rule name="mask" value="^$|http.+">Please enter an url starting with
"http"</rule>
- <required-message>This module requires a valid url.</required-message>
+ <rule name="required" value="true">This module requires a valid url.</rule>
</field>
]]></source>
@@ -613,14 +666,14 @@
<source><![CDATA[
<field name="Value" key="val" type="String">
<rule name="maxLength" value="255">Value length cannot be > 255</rule>
- <required-message>This module requires data for this
+ <rule name="required" value="true">This module requires data for this
attribute.
- </required-message>
+ </rule>
</field>
<field name="Url" key="url" type="String" mapToProperty="Value">
<rule name="maxLength" value="255">Url length cannot be > 255</rule>
<rule name="mask" value="^$|http.+">Please enter an url starting with
"http"</rule>
- <required-message>This module requires a valid url.</required-message>
+ <rule name="required" value="true">This module requires a valid url.</rule>
</field>
]]></source>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]