Skip to content

How can we get Error Message with the error path appended?  #409

Open
@AnkitJha-OMO30

Description

@AnkitJha-OMO30

I am trying to get a custom error message. Below I have mentioned the schema I have used. I am getting the Error Response as mentioned in my message, but the path is not present. I am attaching the error messages with and without the message block.

My Intended format for message has the path of error along with the custom message.

Example Schema:

{
    "$id": "https://saisonomni.com/loanapplication.schema.json",
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
        "additionalProperties": false,
        "properties": {
            "details": {
                "type": "object",
                "properties": {
                    "phone": {
                        "type": "string",
                        "pattern": "\\+[0-9]{1,3} [0-9]{10}",
                        "message" : {
                                 "pattern": "Phone Number not in right format. Correct format: +91 9876543210"
                        }
                    }
                }
            }
        }
}

Error with the message block:

{
    "errors": [
        "Phone Number not in right format. Correct format: +91 9876543210"
    ]
}

Error without the message block:

{
    "errors": [
        "$.details.phone: does not match the regex pattern \\+[0-9]{1,3} [0-9]{10}"
    ]
}

Error message that is expected

{
    "errors": [
        "$.details.phone: Phone Number not in right format. Correct format: +91 9876543210"
    ]
}

Is there a way to achieve the above error messaging?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions