Metadata Validator element

The goal of the Validator element is to ensure that the user provides the necessary and properly formatted information needed to complete an operation successfully.

The validator can only be used in combination with other fields:

Available validators:

nameDescription
req

Required value.

alpha

Alphabetic value.

alphanum

Alphanumeric value.

dec

Decimal value.

num

Numeric value.

email

E-mail value.

url

URL value.

maxlen

Set the maximum length allowed.

minlen

Set the minimum length required.

lt

Less than.

gt

Greater than.

min

Minimum value.

max

Maximum value.

regexp

Regular expression.

plugin

Creates your form validator.

More information at Creating your own Form Validator plugin.

Parent:

Basic example

  • Value required "req".
  • The value must be decimal "dec".
  • The maximum length of the decimal value is six digits "maxlen".
<input label="Decimal value" name="okp:consulting.decimal">
    <validator type="dec" />
    <validator type="req" />
    <validator type="maxlen" parameter="6" />
</input>

Regular expression

You can use a regular expression if you want a validation that is not included in these predefined. For example, imagine you want to restrict an input to lowercase ASCII values:

<input label="Lowercase value" name="regExp">
    <validator type="regexp" parameter="[a-z]+" />
</input>

 

Table of contents [ Hide Show ]