ajv
Options to configure Ajv. A list of all supported options can be found here
Default value
{
keywords: {},
plugins: [],
locale: null,
options: {
allErrors: true;
}
}Ajv option
allErrorsis always set to true, there is no way to override this as it is used internally for validation
Examples
Enable $data references
See Ajv's documentation about $data references for more details. $data in this example can be substituted for any other supported Ajv option
data() {
return {
options: {
ajv: {
options: {
$data: true
}
}
},
model: {
...
},
jsonSchema: {
...
},
uiSchema: [
...
]
}
}Localize error messages
This example uses ajv-i18n. Any errors will be translated using the locale function provided before the fields gets access to them.
Add Ajv keywords
In this example we will add a custom keyword which checks that the value of the input is not present in the blacklist array
Extend Ajv instance
Note that this is neither tested nor supported but in theory this would give extra Ajv features such as ajv-async and ajv-merge-patch access to the internal Ajv instance running inside vue-form-json-schema.
By adding the required plugin to the plugins section in the ajv options it is possible to load and apply the required plugin to the ajv instance that is used by vue-form-json-schema. This comes in handy when custom error messages must be added with ajv-errors.
Last updated