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

ErrorMessage with Array of strings #70

Open
jlgouwyapizr opened this issue Oct 13, 2020 · 3 comments
Open

ErrorMessage with Array of strings #70

jlgouwyapizr opened this issue Oct 13, 2020 · 3 comments

Comments

@jlgouwyapizr
Copy link

jlgouwyapizr commented Oct 13, 2020

Hey everybody,

I have some issues when i'm trying to put errorMessage with an array, for example, this is my schema :

"pictures": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "A_SPECIFIC_PATTERN_TO_PUT_HERE"
      },
      "errorMessage": {
        "type": "INVALID_MEDIA_PICTURES_ITEMS",
      }
    },

When the pattern doesn't match, I don't receive errorMessage keyword, but instead :

error {
  keyword: 'pattern',
  dataPath: '/media/pictures/0',
  schemaPath: 'media-schema.json/properties/pictures/items/pattern',
  params: {
    pattern: 'A_SPECIFIC_PATTERN_TO_PUT_HERE'
  },
  message: 'should match pattern A_SPECIFIC_PATTERN_TO_PUT_HERE'
}

I would like to receive my INVALID_MEDIA_PICTURES_ITEMS. I have the feeling errorMessage only works with type: object

Am I missing something here ?

@dontbesatisfied
Copy link

Does any one have solution?

@AldrinSalazar
Copy link

Bump

@outbackStack
Copy link

I'm having the same issues with getting the 'errorMessage' when it's a pattern in an array...

banks: {
  type: "array",
  items: {
    type: "object",
    additionalProperties: false,
    properties: {
      bsbNumber: {
        type: "string",
        pattern: "^[0-9]{3}-[0-9]{3}$"
      }
    },
    errorMessage: {
      properties: {
        bsbNumber: "BSB number must be in the format 000-000."
      }
    }
  }
}

the actual error does not contain the keyword "errorMessage", only the keyword "pattern" as bellow

{
    "instancePath": "/banks/0/bsbNumber",
    "schemaPath": "#/properties/banks/items/properties/bsbNumber/pattern",
    "keyword": "pattern",
    "params": {
        "pattern": "^[0-9]{3}-[0-9]{3}$"
    },
    "message": "must match pattern \"^[0-9]{3}-[0-9]{3}$\"",
    "schema": "^[0-9]{3}-[0-9]{3}$",
    "parentSchema": {
        "type": "string",
        "pattern": "^[0-9]{3}-[0-9]{3}$"
    },
    "data": ""
}

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

No branches or pull requests

4 participants