Dynamic field validators
The following field validators are available by default:
Required field
The required field validator can be applied to any field type. It checks that a field value has been entered:
-
the value should not be
null
-
the value should not be empty ("") if the field type is a
String
-
the value should not be empty (length 0) if the field type is a
Collection
orArray
Adding a required field validator can be done with a single key value.
Key | Description |
---|---|
|
Validates the field value and customizes the field control so it visually displays as a required field. |
|
Validates the field value, but does not customize the field control to visually display as a required field. |
No additional settings are available.
If validation fails the field is rejected with a required
message code.
Specifying a custom feedback message is optional.
A default "field is required" message will always be shown.
document-definition:
name: sample-document
content:
- id: name
type: string
validators:
- required
messages:
validation.required: "You MUST enter a name"