santhosh-tekuri/jsonschema

Is it possible to get "all" errors found?

hlindberg opened this issue · 6 comments

Great package, got it to work quickly in my app. When trying it out, I noticed that I only get one error message.
If I fix that problem and run again, I will get the next.

I am printing out the error I get from err := schema.ValidateInterface(doc)

Is there a way to get all error messages?

use %#v print all errors

fmt.Printf("%#v\n", err)

Also make sure you are using latest version

In older versions validation is stopped as soon as error encountered. Seems you are using older version since ValidateInterface method is no longer available in recent versions. It is replaced by Validate method

Hm, I got it yesterday by doing go get github.com/santhosh-tekuri/jsonschema and got github.com/santhosh-tekuri/jsonschema v1.2.4

Meh, I figured it out - it is supposed to be go get github.com/santhosh-tekuri/jsonschema/v5:-)

Bingo!

go run . experiment pizza -f pizzadoc.yaml -s pizzaschema.json 
pizzadoc.yaml: schema validation resulted in error
[I#)] [S#] doesn't validate with https://example.com/pizza.schema2.json#
  [I#/persons/0)] [S#/properties/persons/items] 
    [I#/persons/0)] [S#/properties/persons/items/required] missing properties: 'name'
    [I#/persons/0)] [S#/properties/persons/items/additionalProperties] additionalProperties 'phone' not allowed
  [I#/persons/1)] [S#/properties/persons/items/additionalProperties] additionalProperties 'phone', 'blah' not allowed

Thanks for the quick response!

[I#/persons/0)] [S#/properties/persons/items]

This line in output has empty message.
Is it possible to share pizzadoc pizzaschema files?