Class ValidateTemplate
- All Implemented Interfaces:
TemplateInterface
ValidateTemplate is designed to validate
HTML forms. It performs data validation on sets of
properties (e.g. form values) by comparing the values against
validation constraints that are specified in other variables.
The "glob" attribute defines the set of variables to be
validated, and the "types" attribute maps each variable name
matched by "glob" into the variable that names the validation
tokens for that variable to be validated.
The "types" attribute, which is used to identify the
validation types may contain variables of the form, ${n} where
0 < n < 10 which represent the string value matching the nth wildcard
in the "glob" attribute.
Example: glob=*.*.*.*.* and types=types.${3}.${1}
will validate a.b.c.d.e against the types contained in types.c.a
The default for types is validate.${1}
For each validate request, all properties matching the specified
glob pattern will be validated against pre-loaded validation
keys specified by the glob pattern match types. The result
will be stored in properties prepended by the prefix attribute,
which defaults to the template's prefix.
<validate glob=pattern [prefix=prepend
types=pattern (${1-9}.${1-9})]>
Properties validated by ValidateTemplate
Validation of properties propNames against glob,
regular expression, logic/arithmetic expression, max
value (integer), max length (string), min value(integer), min length (string)
if validation properties exist. If there are n validation properties, then
all n are evaulated. A property can fail on multiple validations.
- types
- contains the user specified validation key glob
pattern to find a space separated list of
validation parameters.
The typest is built from
typesandglob
type1 type2 type3 ...
Example: numeric ssn ...
If emptytype=propName - types.glob
- contains a glob pattern to match against
propNamedefined in the types list. - types.regex
- contains a regular expression pattern to match
against
propNamedefined in the types list. - types.expr
- contains a boolean/arithmetic expression with variable subsititutions to evaluate.
- types.maxint
- contains the maximum an integer value can have
if
propNameis an integer. - types.minint
- contains the minimum an integer value can have
if
propNameis an integer. - types.maxlen
- contains the maximum length of a string if
propNameis a string. - types.minlen
- contains the minimum length of a string if
propNameis a string
Properties set by ValidateTemplate
If validation fails, the error message to be displayed to the user is up to
the developer. ValidateTemplate does not store any error messages.
The default for prepend is validate.
- prepend.numfailed
- contains the number of failed validations.
- prepend.failedlist
- contains the list of query properties that
failed validation along with the type and
reason.
Example: propName:type.reason
query.1:numeric.glob
- Version:
- ValidateTemplate.java
- Author:
- Tony Zhao
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSpecial version of a format that uses uses the previously defined GlobProperties.static classSpecial version of a properties that uses the sub expresions of the supplied glob pattern and type to define the keys 1-9. -
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleaninit(RewriteContext hr) Called before this template processes any tags.void
-
Constructor Details
-
ValidateTemplate
public ValidateTemplate()
-
-
Method Details
-
init
Description copied from class:TemplateCalled before this template processes any tags.- Specified by:
initin interfaceTemplateInterface- Overrides:
initin classTemplate
-
tag_validate
-