Skip to content

Support errorMessage so as to customise validation errors  #371

@jobinkavalam

Description

@jobinkavalam

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions