Validation
Whenever you change data in the forms generated by JSON Forms, it will be validated in the background in order to display any messages that violate the JSON schema.
Validation is handled by AJV and can be customized by passing a custom AJV instance as a prop to the JsonForms
standalone component.
If you do not customize the validator, a default instance will be created for you. That default instance is configured as follows:
You can either create your own instance or you can use the createAjv
function provided by JSON Forms that allows overriding the default options by passing in additional options.
For customizing or localizing AJV error messages we recommend ajv-errors.
#
ValidationModeThere are three different validation modes:
ValidateAndShow
: Validates, emits and shows errors (which is the default)ValidateAndHide
: Validates and emits errors, but does not show themNoValidation
: Does not validate at all
You can set the validation mode in each JSON Form's root component. For example in React it could look like this:
Here you can see the different modes in action
Current mode: ValidateAndShow
Emitted errors: