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

Can we customise the schema validation error message #1075

Closed
yasassri opened this issue Feb 9, 2021 · 1 comment
Closed

Can we customise the schema validation error message #1075

yasassri opened this issue Feb 9, 2021 · 1 comment

Comments

@yasassri
Copy link

yasassri commented Feb 9, 2021

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."**
		},
@Relequestual
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants