Skip to content

Can we customise the schema validation error message #1075

Closed
@yasassri

Description

@yasassri

Can we do something like the below?

"service_name": {
			"type": "string",
			"pattern": "^([0-9A-Za-z]+[-_\\s]?[0-9A-Za-z]+)+$"
                          **"errorMessage": "The service name is not valid. Take a step back."**
		},

Activity

Relequestual

Relequestual commented on Feb 9, 2021

@Relequestual
Member

This is a duplicate of #62
that was revived as #396
and resolved for draft 2019-09 (aka "draft 8").

You can use the output result of a failed validation process (which contains the keywords locations) to then access the error message in your schema.

You will need to determine which subschema is applicable to your situation if multiple subschemas fail.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Relequestual@yasassri

        Issue actions

          Can we customise the schema validation error message · Issue #1075 · json-schema-org/json-schema-spec