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

Custom error messages for patternProperties #35

Open
leoamp opened this issue Dec 28, 2019 · 1 comment
Open

Custom error messages for patternProperties #35

leoamp opened this issue Dec 28, 2019 · 1 comment

Comments

@leoamp
Copy link

leoamp commented Dec 28, 2019

Is there any way where one can add custom error message for pathPattern attributes? Example:

Json schema:

"patternProperties": {
    "^[a-zA-Z0-9]*$":{
        "properties": {
              "model":{"type":"string"},
              "made":{"type":"string"},
              "year":{"type":"string"}
         }
    }
  },
  "additionalProperties":false
 }

Json:

{
  "efgh56789": {
    "model": "civic"
    "made": "toyota"
    "year": "2014"
  }
}

Here, how to add custom error message (ex: Can contain only alphanumeric characters) for the attribute 'efgh56789' in above schema?
Note: The schema can be a nested schema where few of them are 'patternProperties' & few of them are regular ones.

I have asked the same question in SoF:
Ref: link

@epoberezkin epoberezkin changed the title How to add custom error message for pathPattern attributes Custom error messages for patternProperties Mar 3, 2020
@hsnassaad
Copy link

hsnassaad commented Jun 30, 2021

patternProperties will catch all the properties that matches that pattern and anything else is considered additionalProperties so in my case I changed the error message of the additionalProperties and set its value to false to match my requirements

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

No branches or pull requests

3 participants