Validation
Every question can have validation options. All basic angular validators are included in the core
package. There is also the possibility to register custom sync
and async
validators.
Included validation options
required
: booleanmin
: numberminLength
: numbermax
: numbermaxLength
: numberemail
: booleanpattern
: string or regular expression
Example
Custom validators
Implementation
Arguments
A validator can have arguments. The arguments are separated with a :
from the validator id. If there are multiple arguments they can be split with ,
.
See the following examples of possible ids:
custom-vali:test
-custom-vali
would be the id and the validator will get an argument array of['test']
.my-validator
- validator without argumentsmy-complicated-validator:test,value,two
- validator with 3 arguments, the arguments will look like['test', 'value', 'two']
Registration
To register the validator it is required to specify it either in the root module or a child module.
Usage
The validator can then be used in a question definition. It is possible to specify a single custom validator or an array of validators.
Last updated