# How to customize "is a required property" error

**URL:** <https://jsonforms.discourse.group/t/how-to-customize-is-a-required-property-error/2454>\
**Category:** General\
**Created:** [November 14, 2024, 3:47pm UTC](https://jsonforms.discourse.group/t/how-to-customize-is-a-required-property-error/2454 "2024-11-14T15:47:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Talentless-E](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/talentless-e/32/1156_2.png) [@Talentless-E](https://jsonforms.discourse.group/u/Talentless-E)\
**Post date:** [November 14, 2024, 3:47pm UTC](https://jsonforms.discourse.group/t/how-to-customize-is-a-required-property-error/2454/1 "2024-11-14T15:47:59Z")

</div>

I’m trying to use ajv-errors to customize “required” and “minLength” errors. It works perfectly with minLength, but it doesn’t show any error in “required” fields. It seems i have an error, but it couldn’t map to required property (instancePath is empty). Can you help with some example, please?  
ajv-errors: 3.0.0  
jsonforms: 3.4.1

---

<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:** [November 14, 2024, 3:57pm UTC](https://jsonforms.discourse.group/t/how-to-customize-is-a-required-property-error/2454/2 "2024-11-14T15:57:59Z")

</div>

Hi @Talentless-E,

We would need to check in detail why it fails. Likely it’s changing more of the AJV ErrorObject than the message.

You could take a look at [JSON Forms `i18n`](https://jsonforms.io/docs/i18n) support or [AJV’s i18n](https://github.com/ajv-validator/ajv-i18n) for other ways to customize your messages.

---

<div class="post-metadata">

**Author:** ![Talentless-E](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/talentless-e/32/1156_2.png) [@Talentless-E](https://jsonforms.discourse.group/u/Talentless-E)\
**Post date:** [November 14, 2024, 4:15pm UTC](https://jsonforms.discourse.group/t/how-to-customize-is-a-required-property-error/2454/3 "2024-11-14T16:15:38Z")

</div>

I wanted to achive the same result with ajv-errors or something as if i were using i18n method. It’s pretty useful to be able to write errors directly in schema and 99% of customized errors works perfectly fine. Only problem is with “required”  
This is what i get in error btw

```auto
{
    "instancePath": "",
    "schemaPath": "#/errorMessage",
    "keyword": "errorMessage",
    "params": {
        "errors": [
            {
                "instancePath": "",
                "schemaPath": "#/required",
                "keyword": "required",
                "params": {
                    "missingProperty": "url"
                },
                "message": "must have required property 'url'",
                "schema": [
                    "url"
                ],
                "parentSchema": {
                    "type": "object",
                    "properties": {
                        "url": {
                            "type": "string",
                            "minLength": 2
                        },
                        "enabled": {
                            "type": "boolean",
                            "errorMessage": "TEST"
                        }
                    },
                    "required": [
                        "url"
                    ],
                    "errorMessage": {
                        "required": {
                            "url": "INVALID INPUT. This is a required field"
                        }
                    }
                },
                "data": {},
                "emUsed": true
            }
        ]
    },
    "message": "INVALID INPUT. This is a required field",
    "schema": {
        "required": {
            "url": "INVALID INPUT. This is a required field"
        }
    },
    "parentSchema": {
        "type": "object",
        "properties": {
            "url": {
                "type": "string",
                "minLength": 2
            },
            "enabled": {
                "type": "boolean",
                "errorMessage": "TEST"
            }
        },
        "required": [
            "url"
        ],
        "errorMessage": {
            "required": {
                "url": "INVALID INPUT. This is a required field"
            }
        }
    },
    "data": {}
}

```

Correct error is placed inside params.errors[0]. It seems, for some reason, only “required” error  
is mapped in a wrong way

---

<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:** [November 14, 2024, 4:20pm UTC](https://jsonforms.discourse.group/t/how-to-customize-is-a-required-property-error/2454/4 "2024-11-14T16:20:23Z")

</div>

Hi @Talentless-E,

You can write your own wrapper, like `ajv-errors` itself, and fix the error of `ajv-errors` again. Or just [clone/copy ajv-errors](https://github.com/ajv-validator/ajv-errors/blob/7efe8c29c3ea461eef29335e0199742dbc18e791/src/index.ts) and adjust the code yourself.

Alternatively you could process the errors via a [JSON Forms middleware](https://jsonforms.io/docs/middleware) and fix the error there.

---

<div class="post-metadata">

**Author:** ![Talentless-E](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/talentless-e/32/1156_2.png) [@Talentless-E](https://jsonforms.discourse.group/u/Talentless-E)\
**Post date:** [November 14, 2024, 4:24pm UTC](https://jsonforms.discourse.group/t/how-to-customize-is-a-required-property-error/2454/5 "2024-11-14T16:24:26Z")

</div>

Thank you for your help!
