Hi,
I’m attempting to override the error messaging. Please see my schema and ui schema:
Schema:
{
"$schema": "http://json-schema.org/draft-07/schema",
"type": "object",
"properties": {
"Cat": {
"type": "string"
},
"Dog": {
"type": "string"
},
"Fish": {
"type": "string"
}
},
"required": ["Cat", "Dog"],
"errorMessage": {
"required": {
"Cat": "Cat is required"
}
}
}
UI Schema:
{
"type": "VerticalLayout",
"elements": [
{
"type": "Group",
"elements": [
{
"type": "Control",
"scope": "#/properties/Cat",
"label": "Cat"
},
{
"type": "Control",
"scope": "#/properties/Dog",
"label": "Dog"
},
{
"type": "Control",
"scope": "#/properties/Fish",
"label": "Fish"
}
]
}
]
}
and in the component I am using createAjv
and then using ajvErrors
:
ajv = createAjv({
allErrors: true,
verbose: true,
});
constructor() {
ajvErrors(this.ajv);
// Also tried this:
// this.ajv = ajvErrors(this.ajv);
}
html:
<jsonforms
[data]="data"
[schema]="schema"
[uischema]="uischema"
[renderers]="renderers"
[i18n]="i18n"
[ajv]="ajv"
(dataChange)="onDataChange($event)"
validationMode="ValidateAndShow"
></jsonforms>
Notice, the override is kind of recognised (because the default error now doesn’t show) but the new message doesn’t show on that field.
Any help appreciated.
I’d like to be able to override errors generically, in this case, replacing all “required” messages with something else with the option to tailor some and ideally, defining these somewhere outside of the schemas and perhaps in the json-forms props?