Adds an event handler that runs when the element's validation is checked.
The onCustomValidation()
function allows you perform custom validation
in addition to any basic validation that was defined in the Editor.
To invalidate the element, call the reject()
function that is passed
into the validator
callback function and pass it a validation message.
The element's validity is checked when the value of the element changes either by user interaction or programmatically.
Note that validations other than required, including custom validations, are not run on input elements when they don't have a value.
You can use the override
parameter to override previously applied custom validations.
validator(value: number, reject: Function): void
The name of the function or
the function expression to run when the element's custom validation is checked.
When true
, overrides any existing custom validations set for the element so that only the current custom validation applies.
When false
, the current custom validation is added to the previously applied validations and all of them run. The order of execution follows the order the validations were set.
If one of the validations rejects, the rest of the validations won't run.
Defaults to true
, so that omitting the override
property causes the current custom validation to override any other validations.
If multiple validations are set to override explicitly or by default, only the last applied validation will run.
For example, if you add 4 custom validations to an element and set the override
parameter to false
, true
, false
, false
respectively, the first validation won't run
and the remaining validations will run. This is because the second validation overrides the first.