xeipuuv/gojsonschema

Support `errorMessage` so as to customise validation errors

jobinkavalam opened this issue · 0 comments

Currently, the following schema definition,

        {
          "type": "string",
          "pattern": "^\\d+$"
        }

is expected to give errors such as:

Does not match pattern '^\d+$'

Clearly, in the given context a more friendlier message can be used.

Implementations such as ajv support this feature through the errorMessage field, i.e.

        {
          "type": "string",
          "pattern": "^\\d+$",
          "errorMessage": "should be a number"
        }

It will be great to have gojsonschema support that.

Also really appreciate if there is a better alternative to achieve this in gojsonschema.