Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AnkitJha-OMO30 opened this issue May 2, 2023 · 0 comments
Open

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

AnkitJha-OMO30 opened this issue May 2, 2023 · 0 comments

Comments

@AnkitJha-OMO30
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant