java-json-tools/json-schema-validator

Not all errors get shown depending of nested level

buti1021 opened this issue · 1 comments

Errors get only shown on the highest level, errors more nested get ignored, until the outer errors are fixed.

Schema:

{
   "type": "object",
   "title": "The Root Schema",
   "properties": {
      "country": {
         "type": "string",
         "maxLength": 2
      },
      "id": {
         "type": "string",
         "maxLength": 3
      },
      "state": {
         "type": "array",
         "items": {
            "type": "object",
            "properties": {
               "name": {
                  "type": "string",
                  "maxLength": 16
               },
               "id": {
                  "type": "string",
                  "maxLength": 16

               }
}
}
}
}
}
	{
		"country": "BbE",
		"id": "BEC",
		"state": [
			{
				"name": "sadasd",
				"id": "1235613"
			},
			{
				"name": "asdasd",
				"id": "415sdddddddddd6348"
			}
		]
	}

Should raise multiple errors on this json file (2nd state id is too long as well), but only raises 1 error. If you fix the country length, the 2nd get error gets shown

If you look at the validate method, you'll notice that it has a boolean parameter called deepCheck:

ProcessingReport validate(JsonNode instance, boolean deepCheck)
            throws ProcessingException 

This needs to be true when calling validate if you want all nested errors to appear.