Repository: struts-site
Updated Branches:
  refs/heads/master e350c8983 -> 271ed7b46


fix more validators pages


Project: http://git-wip-us.apache.org/repos/asf/struts-site/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts-site/commit/271ed7b4
Tree: http://git-wip-us.apache.org/repos/asf/struts-site/tree/271ed7b4
Diff: http://git-wip-us.apache.org/repos/asf/struts-site/diff/271ed7b4

Branch: refs/heads/master
Commit: 271ed7b46a3d416e4ea5361bf6dc1491d41cb8e8
Parents: e350c89
Author: Aleksandr Mashchenko <amashche...@apache.org>
Authored: Mon Sep 11 22:57:50 2017 +0300
Committer: Aleksandr Mashchenko <amashche...@apache.org>
Committed: Mon Sep 11 22:57:50 2017 +0300

----------------------------------------------------------------------
 .../conditionalvisitor-validator.md             | 31 ++++----
 source/core-developers/email-validator.md       | 79 +++++++++++++-------
 .../fieldexpression-validator.md                | 53 +++++++------
 source/core-developers/regex-validator.md       | 74 +++++++++++-------
 source/core-developers/short-validator.md       | 77 ++++++++++++-------
 .../core-developers/stringlength-validator.md   | 79 +++++++++++++-------
 source/core-developers/visitor-validator.md     | 58 +++++++-------
 7 files changed, 270 insertions(+), 181 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts-site/blob/271ed7b4/source/core-developers/conditionalvisitor-validator.md
----------------------------------------------------------------------
diff --git a/source/core-developers/conditionalvisitor-validator.md 
b/source/core-developers/conditionalvisitor-validator.md
index 51db45f..13161cd 100644
--- a/source/core-developers/conditionalvisitor-validator.md
+++ b/source/core-developers/conditionalvisitor-validator.md
@@ -5,26 +5,21 @@ title: conditionalvisitor validator
 
 # conditionalvisitor validator
 
-####Description####
+### Description
 
+The ConditionalVisitorFieldValidator will forward validation to the 
VisitorFieldValidator only if the expression will evaluate to true.
 
+### Parameters
 
-~~~~~~~
-{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.ConditionalVisitorFieldValidator}
-~~~~~~~
+- `expression` - an OGNL expression which should evaluate to true to pass 
validation to the VisitorFieldValidator.
 
-####Parameters####
+### Examples
 
-
-
-~~~~~~~
-{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.validators.ConditionalVisitorFieldValidator}
-~~~~~~~
-
-####Examples####
-
-
-
-~~~~~~~
-{snippet:id=example|lang=xml|javadoc=true|url=com.opensymphony.xwork2.validator.validators.ConditionalVisitorFieldValidator}
-~~~~~~~
+```
+<field name="colleaguePosition">
+    <field-validator type="conditionalvisitor">
+        <param name="expression">reason == 'colleague' and colleaguePositionID 
== 'OTHER'</param>
+        <message>You must select reason Colleague and position Other</message>
+    </field-validator>
+</field>
+```

http://git-wip-us.apache.org/repos/asf/struts-site/blob/271ed7b4/source/core-developers/email-validator.md
----------------------------------------------------------------------
diff --git a/source/core-developers/email-validator.md 
b/source/core-developers/email-validator.md
index 590020e..4d5235b 100644
--- a/source/core-developers/email-validator.md
+++ b/source/core-developers/email-validator.md
@@ -5,31 +5,54 @@ title: email validator
 
 # email validator
 
-####Description####
-
-
-
-~~~~~~~
-{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.EmailValidator}
-~~~~~~~
-
-####Parameters####
-
-
-
-~~~~~~~
-{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.validators.EmailValidator}
-~~~~~~~
-
-**(\!) Warning**
-
-
-> 
\{snippet:id=parameters\-warning|javadoc=true|url=com\.opensymphony\.xwork2\.validator\.validators\.EmailValidator\}
-
-####Examples####
-
-
-
-~~~~~~~
-{snippet:id=example|lang=xml|javadoc=true|url=com.opensymphony.xwork2.validator.validators.EmailValidator}
-~~~~~~~
+### Description
+
+EmailValidator checks that a given String field, if not empty, is a valid 
email address.
+
+The regular expression used to validate that the string is an email address is:
+
+```
+\\b^['_a-z0-9-\\+](\\.['_a-z0-9-\\+])@[a-z0-9-](\\.[a-z0-9-])\\.([a-z]{2,6})$\\b
+```
+
+You can also specify `expression`, `caseSensitive` and `trim` params as a OGNL 
expression, see the example below.
+
+### Parameters
+
+- `fieldName` - The field name this validator is validating. Required if using 
Plain-Validator Syntax otherwise not required.
+
+Check also documentation of the `RegexpValidator` for more details - the 
EmailValidator is based on it.
+
+> Warning
+> Do not use `${regexExpression}`, `${caseSensitiveExpression}` and 
`${trimExpression}` as an expression as this will turn into infinitive loop!
+
+### Examples
+
+```
+<!-- Plain Validator Syntax -->
+<validators>
+    <validator type="email">
+        <param name="fieldName">myEmail</param>
+        <message>Must provide a valid email</message>
+    </validator>
+</validators>
+ 
+<!-- Field Validator Syntax -->
+<field name="myEmail">
+   <field-validator type="email">
+      <message>Must provide a valid email</message>
+   </field-validator>
+</field>
+ 
+<!-- Field Validator Syntax with expressions -->
+<!-- Only available when used with xml based configuration, if you want to 
have the same
+        flexibility with annotations use @RegexFieldValidator instead -->
+<field name="myEmail">
+   <field-validator type="email">
+      <param name="regexExpression">${emailPattern}</param> <!-- will be 
evaluated as: String getEmailPattern() -->
+      <param name="caseSensitiveExpression">${emailCaseSensitive}</param> <!-- 
will be evaluated as: boolean getEmailCaseSensitive() -->
+      <param name="trimExpression">${trimEmail}</param> <!-- will be evaluated 
as: boolean getTrimEmail() -->
+      <message>Must provide a valid email</message>
+   </field-validator>
+</field>
+```

http://git-wip-us.apache.org/repos/asf/struts-site/blob/271ed7b4/source/core-developers/fieldexpression-validator.md
----------------------------------------------------------------------
diff --git a/source/core-developers/fieldexpression-validator.md 
b/source/core-developers/fieldexpression-validator.md
index ebe1a7c..e65dc65 100644
--- a/source/core-developers/fieldexpression-validator.md
+++ b/source/core-developers/fieldexpression-validator.md
@@ -5,26 +5,33 @@ title: fieldexpression validator
 
 # fieldexpression validator
 
-####Description####
-
-
-
-~~~~~~~
-{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.FieldExpressionValidator}
-~~~~~~~
-
-####Parameters####
-
-
-
-~~~~~~~
-{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.validators.FieldExpressionValidator}
-~~~~~~~
-
-####Examples####
-
-
-
-~~~~~~~
-{snippet:id=example|javadoc=true|lang=xml|url=com.opensymphony.xwork2.validator.validators.FieldExpressionValidator}
-~~~~~~~
+### Description
+
+Validates a field using an OGNL expression.
+
+### Parameters
+
+- `fieldName` - The field name this validator is validating. Required if using 
Plain-Validator Syntax otherwise not required.
+- `expression` - The Ognl expression (must evaluate to a boolean) which is to 
be validated the stack.
+
+### Examples
+
+```
+<!-- Plain Validator Syntax -->
+<validators>
+    <!-- Plain Validator Syntax -->
+    <validator type="fieldexpression">
+       <param name="fieldName">myField</param>
+       <param name="expression"><![CDATA[#myCreditLimit > 
#myGirfriendCreditLimit]]></param>
+       <message>My credit limit should be MORE than my girlfriend</message>
+    <validator>
+     
+    <!-- Field Validator Syntax -->
+    <field name="myField">
+        <field-validator type="fieldexpression">
+            <param name="expression"><![CDATA[#myCreditLimit > 
#myGirfriendCreditLimit]]></param>
+            <message>My credit limit should be MORE than my 
girlfriend</message>
+        </field-validator>
+    </field>
+</vaidators>
+```

http://git-wip-us.apache.org/repos/asf/struts-site/blob/271ed7b4/source/core-developers/regex-validator.md
----------------------------------------------------------------------
diff --git a/source/core-developers/regex-validator.md 
b/source/core-developers/regex-validator.md
index 17018a7..ac123a3 100644
--- a/source/core-developers/regex-validator.md
+++ b/source/core-developers/regex-validator.md
@@ -5,31 +5,49 @@ title: regex validator
 
 # regex validator
 
-####Description####
-
-
-
-~~~~~~~
-{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.RegexFieldValidator}
-~~~~~~~
-
-####Parameters####
-
-
-
-~~~~~~~
-{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.validators.RegexFieldValidator}
-~~~~~~~
-
-**(\!) Warning**
-
-
-> 
\{snippet:id=parameters\-warning|javadoc=true|url=com\.opensymphony\.xwork2\.validator\.validators\.RegexFieldValidator\}
-
-####Examples####
-
-
-
-~~~~~~~
-{snippet:id=example|javadoc=true|lang=xml|url=com.opensymphony.xwork2.validator.validators.RegexFieldValidator}
-~~~~~~~
+### Description
+
+Validates a string field using a regular expression.
+
+### Parameters
+
+- `fieldName` - The field name this validator is validating. Required if using 
Plain-Validator Syntax otherwise not required.
+- `regexp` - The RegExp expression
+- `caseSensitive` - Boolean (Optional). Sets whether the expression should be 
matched against in a case-sensitive way. Default is true.
+- `trim` - Boolean (Optional). Sets whether the expression should be trimmed 
before matching. Default is true.
+- `regexExpression` - String (Optional). Defines regExp expression as an OGNL 
expression - will be evaluated to String.
+- `caseSensitiveExpression` - String (Optional). Defines `caseSensitive` param 
as an OGNL expression - will be evaluated to Boolean.
+- `trimExpression` - String (Optional). Defines trim param as an OGNL 
expression - will be evaluated to Boolean.
+
+You can mix normal params with expression aware params but thus was not tested.
+
+> Warning
+> Do not use `${regexExpression}`, `${caseSensitiveExpression}` and 
`${trimExpression}` as an expression as this will turn into infinitive loop! 
+
+### Examples
+
+```
+<validators>
+    <!-- Plain Validator Syntax -->
+    <validator type="regex">
+        <param name="fieldName">myStrangePostcode</param>
+        <param name="regex"><![CDATA[([aAbBcCdD][123][eEfFgG][456])]]></param>
+    </validator>
+ 
+    <!-- Field Validator Syntax -->
+    <field name="myStrangePostcode">
+        <field-validator type="regex">
+            <param 
name="regex"><![CDATA[([aAbBcCdD][123][eEfFgG][456])]]></param>
+        </field-validator>
+    </field>
+ 
+    <!-- Field Validator Syntax with expressions -->
+    <field name="myStrangePostcode">
+        <field-validator type="regex">
+            <param name="regexExpression">${regexValue}</param> <!-- will be 
evaluated as: String getRegexValue() -->
+            <param 
name="caseSensitiveExpression">${caseSensitiveValue}</param> <!-- will be 
evaluated as: boolean getCaseSensitiveValue() -->
+            <param name="trimExpression">${trimValue}</param> <!-- will be 
evaluated as: boolean getTrimValue() -->
+        </field-validator>
+    </field>
+</validators>
+```

http://git-wip-us.apache.org/repos/asf/struts-site/blob/271ed7b4/source/core-developers/short-validator.md
----------------------------------------------------------------------
diff --git a/source/core-developers/short-validator.md 
b/source/core-developers/short-validator.md
index 5825307..9404bc3 100644
--- a/source/core-developers/short-validator.md
+++ b/source/core-developers/short-validator.md
@@ -5,31 +5,52 @@ title: short validator
 
 # short validator
 
-####Description####
-
-
-
-~~~~~~~
-{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.ShortRangeFieldValidator}
-~~~~~~~
-
-####Parameters####
-
-
-
-~~~~~~~
-{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.validators.ShortRangeFieldValidator}
-~~~~~~~
-
-**(\!) Warning**
-
-
-> 
\{snippet:id=parameters\-warning|javadoc=true|url=com\.opensymphony\.xwork2\.validator\.validators\.ShortRangeFieldValidator\}
-
-####Examples####
-
-
-
-~~~~~~~
-{snippet:id=example|javadoc=true|lang=xml|url=com.opensymphony.xwork2.validator.validators.ShortRangeFieldValidator}
-~~~~~~~
+### Description
+
+Field Validator that checks if the short specified is within a certain range.
+
+### Parameters
+
+- `fieldName` - The field name this validator is validating. Required if using 
Plain-Validator Syntax otherwise not required.
+- `min` - the minimum value (if none is specified, it will not be checked).
+- `max` - the maximum value (if none is specified, it will not be checked).
+- `parse` - if set to true, minExpression and maxExpression will be evaluated 
to find min/max.
+- `minExpression` - expression to calculate the minimum value (if none is 
specified, it will not be checked).
+- `maxExpression` - expression to calculate the maximum value (if none is 
specified, it will not be checked).
+
+You can either use the `min` / `max` value or `minExpression` / 
`maxExpression` (when `parse` is set to `true`) - using expression can be 
slightly slower, see the example below.
+
+> Warning
+> Do not use `${minExpression}` and `${maxExpression}` as an expression as 
this will turn into infinitive loop!
+
+### Examples
+
+```
+<validators>
+    <!-- Plain Validator Syntax -->
+    <validator type="short">
+        <param name="fieldName">age</param>
+        <param name="min">20</param>
+        <param name="max">50</param>
+        <message>Age needs to be between ${min} and ${max}</message>
+    </validator>
+ 
+    <!-- Field Validator Syntax -->
+    <field name="age">
+        <field-validator type="short">
+            <param name="min">20</param>
+            <param name="max">50</param>
+            <message>Age needs to be between ${min} and ${max}</message>
+        </field-validator>
+    </field>
+ 
+    <!-- Field Validator Syntax with expression -->
+    <field name="age">
+        <field-validator type="short">
+            <param name="minExpression">${minValue}</param> <!-- will be 
evaluated as: Short getMinValue() -->
+            <param name="maxExpression">${maxValue}</param> <!-- will be 
evaluated as: Short getMaxValue() -->
+            <message>Age needs to be between ${min} and ${max}</message>
+        </field-validator>
+    </field>
+</validators>
+```

http://git-wip-us.apache.org/repos/asf/struts-site/blob/271ed7b4/source/core-developers/stringlength-validator.md
----------------------------------------------------------------------
diff --git a/source/core-developers/stringlength-validator.md 
b/source/core-developers/stringlength-validator.md
index bcc9088..403ca89 100644
--- a/source/core-developers/stringlength-validator.md
+++ b/source/core-developers/stringlength-validator.md
@@ -5,31 +5,54 @@ title: stringlength validator
 
 # stringlength validator
 
-####Description####
-
-
-
-~~~~~~~
-{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.StringLengthFieldValidator}
-~~~~~~~
-
-####Parameters####
-
-
-
-~~~~~~~
-{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.validators.StringLengthFieldValidator}
-~~~~~~~
-
-**(\!) Warning**
-
-
-> 
\{snippet:id=parameters\-warning|javadoc=true|url=com\.opensymphony\.xwork2\.validator\.validators\.StringLengthFieldValidator\}
-
-####Examples####
-
-
-
-~~~~~~~
-{snippet:id=example|javadoc=true|lang=xml|url=com.opensymphony.xwork2.validator.validators.StringLengthFieldValidator}
-~~~~~~~
+### Description
+
+StringLengthFieldValidator checks that a String field is of a certain length. 
If the `minLength` parameter is specified, it will make sure that the String 
has at least that many characters. If the `maxLength` parameter is specified, 
it will make sure that the String has at most that many characters. The `trim` 
parameter determines whether it will `String#trim()` the String before 
performing the length check. If unspecified, the String will be trimmed.
+
+### Parameters
+
+- `fieldName` - The field name this validator is validating. Required if using 
Plain-Validator Syntax otherwise not required.
+- `maxLength` - Integer. The max length of the field value. Default ignore.
+- `minLength` - Integer. The min length of the field value. Default ignore.
+- `trim` - (Optional) Boolean, default true. Trim the field value before 
evaluating its min/max length. Default true.
+- `maxLengthExpression` - (Optional) String. Defines the max length param as 
an OGNL expression.
+- `minLengthExpression` - (Optional) String. Defines the min length param as 
an OGNL expression.
+- `trimExpression` - (Optional) String. Defines th trim param as an OGNL 
expression.
+
+> Warning
+> Do not use `${minLengthExpression}`, `${maxLengthExpression}` and 
`${trimExpression}` as an expression as this will turn into infinitive loop!
+
+### Examples
+
+```
+<validators>
+    <!-- Plain Validator Syntax -->
+    <validator type="stringlength">
+        <param name="fieldName">myPurchaseCode</param>
+        <param name="minLength">10</param>
+        <param name="maxLength">10</param>
+        <param name="trim">true</param>
+        <message>Your purchase code needs to be 10 characters long</message>
+    </validator>
+ 
+    <!-- Field Validator Syntax -->
+    <field name="myPurchaseCode">
+        <field-validator type="stringlength">
+             <param name="minLength">10</param>
+             <param name="maxLength">10</param>
+             <param name="trim">true</param>
+             <message>Your purchase code needs to be 10 characters 
long</message>
+        </field-validator>
+    </field>
+ 
+    <!-- Field Validator Syntax with expression -->
+    <field name="myPurchaseCode">
+        <field-validator type="stringlength">
+             <param name="minLengthExpression">${minLengthValue}</param> <!-- 
will be evaluated as: Integer getMinLengthValue() -->
+             <param name="maxLengthExpression">${maxLengthValue}</param> <!-- 
will be evaluated as: Integer getMaxLengthValue() -->
+             <param name="trimExpression">${trimValue}</param> <!-- will be 
evaluated as: boolean getTrimValue() -->
+             <message>Your purchase code needs to be 10 characters 
long</message>
+        </field-validator>
+    </field>
+</validators>
+```

http://git-wip-us.apache.org/repos/asf/struts-site/blob/271ed7b4/source/core-developers/visitor-validator.md
----------------------------------------------------------------------
diff --git a/source/core-developers/visitor-validator.md 
b/source/core-developers/visitor-validator.md
index 55b2324..36aa9d8 100644
--- a/source/core-developers/visitor-validator.md
+++ b/source/core-developers/visitor-validator.md
@@ -5,31 +5,33 @@ title: visitor validator
 
 # visitor validator
 
-####Description####
-
-
-
-~~~~~~~
-{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.VisitorFieldValidator}
-~~~~~~~
-
-####Parameters####
-
-
-
-~~~~~~~
-{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.validators.VisitorFieldValidator}
-~~~~~~~
-
-####Examples####
-
-
-
-~~~~~~~
-{snippet:id=example|lang=xml|javadoc=true|url=com.opensymphony.xwork2.validator.validators.VisitorFieldValidator}
-~~~~~~~
-
-
-~~~~~~~
-{snippet:id=explanation|javadoc=true|url=com.opensymphony.xwork2.validator.validators.VisitorFieldValidator}
-~~~~~~~
+### Description
+
+The VisitorFieldValidator allows you to forward validation to object 
properties of your action using the object's own validation files. This allows 
you to use the `ModelDriven` development pattern and manage your validations 
for your models in one place, where they belong, next to your model classes. 
The VisitorFieldValidator can handle either simple Object properties, 
Collections of Objects, or Arrays.
+
+### Parameters
+
+- `fieldName` - field name if plain-validator syntax is used, not needed if 
field-validator syntax is used.
+- `context` - the context of which validation should take place. Optional.
+- `appendPrefix` - the prefix to be added to field. Optional.
+
+### Examples
+
+```
+<validators>
+    <!-- Plain Validator Syntax -->
+    <validator type="visitor">
+        <param name="fieldName">user</param>
+        <param name="context">myContext</param>
+        <param name="appendPrefix">true</param>
+    </validator>
+ 
+    <!-- Field Validator Syntax -->
+    <field name="user">
+       <field-validator type="visitor">
+          <param name="context">myContext</param>
+          <param name="appendPrefix">true</param>
+       </field-validator>
+    </field>
+</validators>
+```

Reply via email to