How to customize "is a required property" error

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

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 support or AJV’s i18n for other ways to customize your messages.

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

{
    "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

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 and adjust the code yourself.

Alternatively you could process the errors via a JSON Forms middleware and fix the error there.

Thank you for your help!