Field validator definitions
PolicyCenter stores field validator definitions in the fieldvalidators.xml file, located in Guidewire Studio under . The fieldvalidators.xml file contains a list of validator specifications for individual fields in PolicyCenter. The fieldvalidators.xml file contains the following sections:
|
XML element |
Description |
More information |
|---|---|---|
|
|
Top XML element for the fieldvalidators.xml file. |
|
|
|
Subelement that defines all of the validators. Each validator must have a unique name by which you can reference it. |
Using the fieldvalidators.xml file, you can do the following:
- You can modify existing validators. For example, it is common for each installation site to represent policy numbers differently. You can define field validation to reflect these changes.
- You can add new validators for existing fields or custom extension fields.
The following XML example illustrates the structure of the fieldvalidators.xml file:
<FieldValidators>
<ValidatorDef name="Email"
description="Validator.Email"
input-mask=""
value=".+@.+"/>
<ValidatorDef name="SSN"
description="Validator.SSN"
input-mask="###-##-####"
value="[0-9]{3}-[0-9]{2}-[0-9]{4}|[0-9]{2}-[0-9]{7}?"
/>
...
</FieldValidators>
In the previous example, each validator definition specifies a value and an
input-mask. These attributes have different uses, as follows:
|
|
A |
|
|
An |
The input mask guides the user to enter to valid sequences for the regular expression defined
in the value attribute. After the user enters a value, PolicyCenter uses the regular expression to validate the field data as
it sets the field on the object.
<FieldValidators>
The <FieldValidators> element
is the root element in the fieldvalidators.xml file. It contains the XML subelement
<ValidatorDef>.
<ValidatorDef>
The <ValidatorDef> subelement
of <FieldValidators>
is the beginning element for the definition of a validator. This element
has the following attributes:
- description
- floor, ceiling
- input-mask
- name
- placeholder-char
- validation-level
- validation-type
- value
description
The description
attribute specifies the validation message to show to a user who enters
bad input. The description refers to a key in the display_languageCode.properties file that contains
the actual description text. The naming convention for this display key
is Validator.validator_name.
In the display text in the properties file,
{0} represents the name
of the field in question. PolicyCenter
determines this at runtime dynamically.
floor, ceiling
The floor
and ceiling attributes
are optional attributes that specify the minimum (floor) and maximum (ceiling) values for the field.
For example, you can limit the range to 100-200 by setting floor="100" and ceiling="200".
Use floor and ceiling range values for
numeric fields only. For example, use the floor and ceiling attributes
to define a Money validator:
<ValidatorDef description="Validator.Money"
input-mask="" name="Money"
ceiling="9999999999999999.99"
floor="-9999999999999999.99"
value=".*"/>
input-mask
The input-mask attribute is optional. It specifies a visual indication of the characters that the user can enter. PolicyCenter displays the input mask temporarily to the user during data entry. When the user starts to enter text, the input mask is no longer visible.
The input mask definition consists of the # symbol and other characters:
- The
#symbol represents any character the user can type. - Any other character represents itself in a non-editable form. For example, in an input mask of
###-###-##, the two hyphen characters are a non-editable part of the input field. - Any empty input mask of
""is the same as not having the attribute at all. - A special case is a mask with fixed characters on the end. PolicyCenter displays those characters outside of the text field. For example
####mphappears as a field####withmphon the outside end of it.
name
The name attribute specifies the name of the validator. A field definition uses this attribute to specify which validator applies to the field.
placeholder-char
The placeholder-char attribute specifies a replacement value for the input mask display character, which defaults to a period (.) For example, use the placeholder-char attribute to display a dash character instead of the default period.
validation-level
This attribute can be set to one of the following values:
Attribute |
Description |
|---|---|
|
Disables the validator. |
|
Ignores warnings or partial validation. |
|
Treats partially validation or warnings as errors. |
validation-type
Specifies whether to use a regular expression or Gosu class for the validation.
This attribute can be set to one of the following values:
Attribute |
Description |
|---|---|
|
The |
|
The |
value
The value attribute specifies the acceptable values for the field. It is in the form of a regular expression. PolicyCenter does not persist this value (the regular expression definition) to the database.
Use regular expressions with String values only. Use floor and ceiling range values for numeric fields, for example, Money.
PolicyCenter uses the Java regex package described in the following location for regular expression parsing:
https://docs.oracle.com/javase/8/docs/api/java/util/regex/package-summary.html
The following list describes some of the more useful items:
|
Parentheses define the order in which PolicyCenter evaluates an expression, just as with any parentheses. |
|
Brackets indicate acceptable values. For example:
|
|
Braces indicate the number of characters. For example:
|
|
A question mark indicates one or zero occurrences of the preceding value. For example, |
|
Values within parentheses followed by a question mark are optional. For example, |
|
An asterisk means zero or more of the preceding value. For example, |
|
A plus sign means one or more of the preceding value. For example, |
|
A period is a wildcard character. For example:
|
