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

[Feature Request] Adding custom error message for each json field #517

Open
antonkhmara opened this issue Oct 28, 2024 · 1 comment
Open

Comments

@antonkhmara
Copy link

It would be helpful to have a way to override the default error message, either through interceptors or by specifying it within the JSON schema.

For example, consider this object:

           "reference": {
              "maxLength": 2147483647,
              "minLength": 6,
              "pattern": "^[A-Za-z0-9 /.-]*$",
              "type": "string",
              "description": "Reference Data.",
              "example": "Az074-124",
              "errorMessage": [
                {
                  "pattern": "must be alphanumeric and can contain only the following special characters: /.-"
                }
              ]
            }

In this case, instead of displaying the default error message:
#/payoutDefaults/compliance/reference: string [@#] does not match pattern ^[A-Za-z0-9 /.-]*$,
we would see the message defined in the errorMessage property:
#/payoutDefaults/compliance/reference: must be alphanumeric and can contain only the following special characters: /.-.

It would be greatly appreciated if there’s already a way to override the default error message! 🙏

@erosb
Copy link
Contributor

erosb commented Oct 29, 2024

Hello, this library is in maintenance mode, hence it is very unlikely to see new features (see the deprecation notice.

The successor library has better support for programmatically consumable validation errors, so you may consider migrating to it, then it will be fairly feasible to generate your own error messages.

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

2 participants