Closed littlebee closed 5 years ago
I have a schema with nested "required"s like this:
{ "$id": "http://json-schema.org/draft-04/schema#", "$schema": "http://json-schema.org/draft-04/schema#", "version": "0.2.0", "type": "object", "title": "exampleNested", "description": "Example validation for nested schema", "required": ["author", "editor"], "additionalProperties": true, "properties": { "author": { "$ref": "#/definitions/person" }, "editor": { "$ref": "#/definitions/person" }, "description": { "$ref": "#/definitions/descriptionText" } }, "definitions": { "person": { "type": "object", "required": ["name"], "additionalProperties": false, "properties": { "name": { "$ref": "#/definitions/personName" }, "email": { "$ref": "#/definitions/personEmail" } } }, "personName": { "type": "string", "minLength": 2, "pattern": "[a-zA-Z]" }, "personEmail": { "type": "string", "minLength": 2, "pattern": "^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$" }, "descriptionText": { "type": "string", "minLength": 1 } } }
when I validate JSON missing just one of the two required 'name' attributes, like this:
{ "description": "example description", "author": { "name": "Me", "email": "me@memyselfandi.org" }, "editor": { "email": "editor@someplaceeditorswork.com" } }
The error is 'requires property "name"'
Is there anyway to indicate which of the two "name"s are missing?
nevermind. It looks like the stack attribute on the errors returned has a more complete error message.
stack
Thank you for this awesome lib!
I have a schema with nested "required"s like this:
when I validate JSON missing just one of the two required 'name' attributes, like this:
The error is 'requires property "name"'
Is there anyway to indicate which of the two "name"s are missing?