# Custom error message with Ajv-errors on nested schema

**URL:** <https://jsonforms.discourse.group/t/custom-error-message-with-ajv-errors-on-nested-schema/995>\
**Category:** General\
**Created:** [September 3, 2022, 2:46pm UTC](https://jsonforms.discourse.group/t/custom-error-message-with-ajv-errors-on-nested-schema/995 "2022-09-03T14:46:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![newbieJson](https://avatars.discourse-cdn.com/v4/letter/n/4bbf92/32.png) [@newbieJson](https://jsonforms.discourse.group/u/newbieJson)\
**Post date:** [September 3, 2022, 2:46pm UTC](https://jsonforms.discourse.group/t/custom-error-message-with-ajv-errors-on-nested-schema/995/1 "2022-09-03T14:46:25Z")

</div>

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)**

 ![image](https://global.discourse-cdn.com/free1/uploads/jsonforms/original/1X/b7e731a106f8699161a554f44bc6757b1396500c.png)

**2. Fields inside an array (not working)**

 ![image](https://global.discourse-cdn.com/free1/uploads/jsonforms/original/1X/312ffeebba84f6d5a067be95a47e1d4299839362.png)  
schema.json

```auto
    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

```auto
    const uischema = {
        type: "VerticalLayout",
        elements: [
            {
                type: "Control",
                scope: "#/properties/comments",
            },
        ],
    };

```

**3. Added allOf based on Ajv-errors documentation (not working)**

 ![image](https://global.discourse-cdn.com/free1/uploads/jsonforms/original/1X/06c0be72ecdec54897df9044e0a5724772afae3d.png)  
schema.json

```auto
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

```auto
    const uischema = {
        type: "VerticalLayout",
        elements: [
            {
                type: "Control",
                scope: "#/properties/comments",
            },
        ],
    };

```

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [September 11, 2022, 12:53pm UTC](https://jsonforms.discourse.group/t/custom-error-message-with-ajv-errors-on-nested-schema/995/2 "2022-09-11T12:53:04Z")

</div>

Hi @newbieJson,

For scenario 2: `ajv-errors` is a third party offering, so I’m not sure why it goes wrong here. JSON Forms just consumes the errors from AJV as they are produced, so this can’t be an error on the side of JSON Forms.

For scenario 3: It seems our React Table renderer is not able to properly handle the `allOf`. This is why you get the “No applicable cell found” error. This is a bug. If you can reproduce this with the latest version of JSON Forms, please open an issue against the main repo.

---

<div class="post-metadata">

**Author:** ![newbieJson](https://avatars.discourse-cdn.com/v4/letter/n/4bbf92/32.png) [@newbieJson](https://jsonforms.discourse.group/u/newbieJson)\
**Post date:** [September 11, 2022, 3:21pm UTC](https://jsonforms.discourse.group/t/custom-error-message-with-ajv-errors-on-nested-schema/995/3 "2022-09-11T15:21:15Z")

</div>

Yes, I’m using the latest jsonform library version, “3.0.0-rc.1”

![image](https://global.discourse-cdn.com/free1/uploads/jsonforms/original/1X/af7bf7e3366bf61af784642d1b7ba4ae799dec53.png)
