Add translations for validators. New translations will be merged with existing translations and overwritten if they already exists.
the map with translation for validators
Add validators to an element.
the element to add validator to
the defintion of validators to be addede.
Optional
isBaseConfigs: booleanis a boolean which indicates if this configuration should always lay as a base configuration even if overlaying code is changing its validators.
As an example there is FEmailTextField which sets its own EmailValidator
in the constructor. Then the app-code can add its own validatorsConfig on
top of that (example: required: { enabled: $someValue } }
). Setting
isBaseConfigs to true preserves the validatorConfig set by
FEmailTextField as the app code changes the required validatorConfig
(which triggers addValidatorsToElement()
again)
Clears all validation states.
Clears any previous set error messages for validators (including default texts)
Gets a registered validator by its name, i.e., Validator.name.
The name of the validator to retrieve.
The registered validator with the given name.
Check if given element(s) are valid.
When passing multiple elements all of them must be valid. For non-input
elements (fieldsets, divs, etc) it checks whenever all descendants are
valid. Returns true
if array is empty.
Note: this function does not update the validity state (i.e. run validators) but only checks the current state! Use ValidationServiceInterface.validateElement to update state.
Element instance or id.
Optional
root: Element | DocumentElement (or document) to query when looking up elements by id.
Resolves to true
if all given elements (or descendants) are valid. Empty array resolves to true
.
Use ValidationServiceInterface.validateElement instead.
Register a validator. To be used when a customer validator is needed.
Remove element from ValidationService.
Element to remove validators from.
Reset validation status for given element If passed element is a not a validatable element, the state of all validatable children is updated instead.
Element instance or id
Set element as invalid with the given strnig as error message.
Element instance or id.
Error message to present.
Set error messages for one or more validators.
The mapping should contain an object with the validator descriptor as key and the error message as value. A descriptor is a dot separated list of keywords:
text
, radio
, checkbox
, select
or textarea
).When multiple validator names are given the first one is the validator yielding the error and any subsequent validators is used when the first validator is combined with these validators (no matter if those yield an error or not).
required
- the error message when required
yields an error.required.date
- the error message when required
yields an error on an
input field which also uses the date
validator.required.radio
- the error message when required
yield an error on an
input field of type radiobutton.required.whitelist.textarea
- the error message when required
yield an
error on an textarea which also uses the whitelist
validator.New translations will be merged with existing messages and overwritten if
they already exists. Do note that if a more specific error message
already exists the specific one will not be affected (e.g. setting the
error for required
whould not affect required.radio
if it exists).
Set clear
to true
to reset all previous messages (overwrite instead
of merge).
the map with error messages for validators
Optional
options: { clear?: boolean }Set or update validation state on element(s).
Can be used to restore state after page reload, or to set all elements in a subform to submitted.
If passed element is a not a validatable element, the state of all validatable children is updated instead.
Element instance or id
The state to be set
ValidityEvent validityMode
Use ValidationServiceInterface.setSubmitted, ValidationServiceInterface.setTouched, ValidationServiceInterface.setError, ValidationServiceInterface.resetState or request a specific function is added if you have another use-case.
Set submitted
flag on the given Element.
If passed element is not a validatable element the state of all validatable children is updated instead.
Element instance or id.
Set touched
flag on the given Element.
If passed element is not a validatable element the state of all validatable children is updated instead.
Element instance or id.
Validate all validatable descendants of given element.
The top element to validate.
Update validation status of given element.
Element instance or id. Element must be attached to document
.
Whether any of the fields are touched