json-schema icon indicating copy to clipboard operation
json-schema copied to clipboard

How can I get errors for all instanceLocation?

Open sukeshpabolu opened this issue 1 year ago • 2 comments

Let's consider the following schema

{
    "$id": "https://example.com/user-data",
    "$schema": "http://json-schema.org/draft-07/schema",
    "type": "object",
    "properties": {
      "name": { "type": "string", "default": "Unknown" },
      "email": { 
		"type": "string", 
		"format": "email",
	},
      "tags": {
        	"type": "array",
       		"minItems": 3,
        	"items": { "type": "string", "minLength": 2 }
      },
      "score": { "type": "integer", "minimum": 0 },
      "date": { "type": "integer", "format": "unix-time" },
			"nospace": {
				"pattern": "^\\S*$",
				"type": "string"
			},
			"extra": {
				"anyOf": [
				{
					"type": "string"
				},
				{
					"type": "null"
				}
			]
		}
    },
    "required": ["name", "email", "tags", "score", "extra"],
  }

I am getting errors only for tags property for the following json

{
    "name": "Unknown",
    "email": "",
    "tags": [],
    "score": -50,
    "extra": 123
  }

sukeshpabolu avatar Apr 23 '24 08:04 sukeshpabolu

Currently the library only supports short circuit evaluation, so it will stop evaluating after the first error.

However, I have the all-errors functionality implemented, so you can expect that to be released relatively soon.

(Related discussion: https://github.com/hyperjump-io/json-schema/discussions/32)

jdesrosiers avatar Apr 23 '24 22:04 jdesrosiers

Okay then eagerly waiting 😊

sukeshpabolu avatar Apr 25 '24 07:04 sukeshpabolu

This functionality was released with v1.9.0 on May 3. Sorry for forgetting to update this thread.

jdesrosiers avatar Jul 22 '24 19:07 jdesrosiers