Repository: struts-site Updated Branches: refs/heads/master bf29f7abc -> e350c8983
fix 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/e350c898 Tree: http://git-wip-us.apache.org/repos/asf/struts-site/tree/e350c898 Diff: http://git-wip-us.apache.org/repos/asf/struts-site/diff/e350c898 Branch: refs/heads/master Commit: e350c8983569a3ed639ed978e6899b52c6e593b5 Parents: bf29f7a Author: Aleksandr Mashchenko <amashche...@apache.org> Authored: Mon Sep 11 00:46:45 2017 +0300 Committer: Aleksandr Mashchenko <amashche...@apache.org> Committed: Mon Sep 11 00:46:45 2017 +0300 ---------------------------------------------------------------------- source/core-developers/date-validator.md | 4 +- source/core-developers/expression-validator.md | 31 ++++----- source/core-developers/int-validator.md | 77 +++++++++++++-------- source/core-developers/required-validator.md | 1 - source/core-developers/url-validator.md | 23 +++--- 5 files changed, 73 insertions(+), 63 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts-site/blob/e350c898/source/core-developers/date-validator.md ---------------------------------------------------------------------- diff --git a/source/core-developers/date-validator.md b/source/core-developers/date-validator.md index f8e0f3c..38db7e1 100644 --- a/source/core-developers/date-validator.md +++ b/source/core-developers/date-validator.md @@ -13,14 +13,14 @@ Field Validator that checks if the date supplied is within a specific range. ### Parameters -- `fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required. +- `fieldName` - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required. - `min` - the min date range. If not specified will not be checked. - `max` - the max date range. If not specified 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. +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! http://git-wip-us.apache.org/repos/asf/struts-site/blob/e350c898/source/core-developers/expression-validator.md ---------------------------------------------------------------------- diff --git a/source/core-developers/expression-validator.md b/source/core-developers/expression-validator.md index bc2c803..6ab1a38 100644 --- a/source/core-developers/expression-validator.md +++ b/source/core-developers/expression-validator.md @@ -5,26 +5,21 @@ title: expression validator # expression validator -####Description#### +### Description +A Non-Field Level validator that validates based on regular expression supplied. +### Parameters -~~~~~~~ -{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.ExpressionValidator} -~~~~~~~ +- `expression` - the Ognl expression to be evaluated against the stack (Must evaluate to a Boolean). -####Parameters#### +### Examples - - -~~~~~~~ -{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.validators.ExpressionValidator} -~~~~~~~ - -####Examples#### - - - -~~~~~~~ -{snippet:id=example|lang=xml|javadoc=true|url=com.opensymphony.xwork2.validator.validators.ExpressionValidator} -~~~~~~~ +``` +<validators> + <validator type="expression"> + <param name="expression"> .... </param> + <message>Failed to meet Ognl Expression .... </message> + </validator> +</validators> +``` http://git-wip-us.apache.org/repos/asf/struts-site/blob/e350c898/source/core-developers/int-validator.md ---------------------------------------------------------------------- diff --git a/source/core-developers/int-validator.md b/source/core-developers/int-validator.md index 0a4d060..f50b1a9 100644 --- a/source/core-developers/int-validator.md +++ b/source/core-developers/int-validator.md @@ -5,31 +5,52 @@ title: int validator # int validator -####Description#### - - - -~~~~~~~ -{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.IntRangeFieldValidator} -~~~~~~~ - -####Parameters#### - - - -~~~~~~~ -{snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.validators.IntRangeFieldValidator} -~~~~~~~ - -**(\!) Warning** - - -> \{snippet:id=parameters\-warning|javadoc=true|url=com\.opensymphony\.xwork2\.validator\.validators\.IntRangeFieldValidator\} - -####Examples#### - - - -~~~~~~~ -{snippet:id=example|javadoc=true|lang=xml|url=com.opensymphony.xwork2.validator.validators.IntRangeFieldValidator} -~~~~~~~ +### Description + +Field Validator that checks if the integer 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="int"> + <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="int"> + <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="int"> + <param name="minExpression">${minValue}</param> <!-- will be evaluated as: Integer getMinValue() --> + <param name="maxExpression">${maxValue}</param> <!-- will be evaluated as: Integer 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/e350c898/source/core-developers/required-validator.md ---------------------------------------------------------------------- diff --git a/source/core-developers/required-validator.md b/source/core-developers/required-validator.md index 8e6db62..5d38592 100644 --- a/source/core-developers/required-validator.md +++ b/source/core-developers/required-validator.md @@ -30,6 +30,5 @@ RequiredFieldValidator checks if the specified field is not null. <message>username must not be null</message> </field-validator> </field> - </validators> ``` http://git-wip-us.apache.org/repos/asf/struts-site/blob/e350c898/source/core-developers/url-validator.md ---------------------------------------------------------------------- diff --git a/source/core-developers/url-validator.md b/source/core-developers/url-validator.md index 335fae7..7ec2d19 100644 --- a/source/core-developers/url-validator.md +++ b/source/core-developers/url-validator.md @@ -5,23 +5,19 @@ title: url validator # url validator -####Description#### +### Description -URLValidator checks that a given field is a String and a valid URL +URLValidator checks that a given field is a String and a valid URL. -Parameters +### Parameters -+ fieldName \- The field name this validator is validating\. Required if using Plain\-Validator Syntax otherwise not required +- `fieldName` - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required. +- `urlRegexExpression` - The regex defined as expression used to validate url. If not defined 'urlRegex' will be used instead. +- `urlRegex` - The regex used to validate url. If not defined default regex will be used. -+ urlRegexExpression \- The regex defined as expression used to validate url\. If not defined 'urlRegex' will be used instead +### Examples -+ urlRegex \- The regex used to validate url\. If not defined default regex will be used - -####Examples#### - - - -~~~~~~~ +``` <validators> <!-- Plain Validator Syntax --> <validator type="url"> @@ -36,7 +32,6 @@ Parameters </field-validator> </field> </validators> - -~~~~~~~ +``` See more details in [UrlValidator Annotation](url-validator-annotation.html)