Hi,
I have tried the template part of Ajv-errors documentation in changing the displayed error message under a text field. I tried to add the same logic into my nested schema but I can’t get it to display the custom error message.
The schema i’m working on have deep layers of nested properties and items. It will be too big for me to post it here.
Please advise. Thanks in advance.
1. Single object fields based on the template provided in Ajv-errors (no issue)
2. Fields inside an array (not working)
schema.json
const schema = {
type: "object",
properties: {
comments: {
type: "array",
items: {
type: "object",
properties: {
message: {
type: "string",
maxLength: 5,
},
enum: {
type: "string",
enum: ["foo", "bar"],
},
},
errorMessage: {
properties: {
message: "size should be a number bigger or equal to 4, current value is",
}
},
},
},
},
};
uischema.json
const uischema = {
type: "VerticalLayout",
elements: [
{
type: "Control",
scope: "#/properties/comments",
},
],
};
3. Added allOf based on Ajv-errors documentation (not working)
schema.json
const schema = {
type: "object",
properties: {
comments: {
type: "array",
items: {
type: "object",
allOf: [
{
properties: {
message: {
type: "string",
maxLength: 5,
},
enum: {
type: "string",
enum: ["foo", "bar"],
},
},
},
],
errorMessage: {
properties: {
message:
"size should be a number bigger or equal to 4, current value is",
},
},
},
},
},
};
uischema.json
const uischema = {
type: "VerticalLayout",
elements: [
{
type: "Control",
scope: "#/properties/comments",
},
],
};