ajv-validator / ajv-errors

Custom error messages in JSON Schemas for Ajv validator
https://ajv.js.org
MIT License
284 stars 18 forks source link

Not getting custom error message for "pattern" keyword #150

Closed ktn05 closed 1 year ago

ktn05 commented 1 year ago

Hi,

schema,

 name: {
    type: 'string',
    pattern: '^[A-Za-z0-9-_]+$',
    errorMessage: {
      pattern: 'letters, digits, hyphen and underscore are only allowed'
    }
  }

Im getting the default error message for 'pattern' keyword i.e "must match pattern \"^[A-Za-z0-9-_]+$\", instead of the message that i have defined.