Skip to content

[Help Wanted] How can I get descriptive error messages when the schema is invalid.  #56

Description

@JeelRajodiya

I have the following schema

{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "array",
    "items": {
        "type": "string"
    }
}

and following data

[1,2,3]

Now when I validate the schema, the I get the following error

{"keyword":"https://json-schema.org/keyword/items","absoluteKeywordLocation":"http://example.com/schemas/string#/items","instanceLocation":"#","valid":false,
"errors":[{"keyword":"https://json-schema.org/evaluation/validate","absoluteKeywordLocation":"http://example.com/schemas/string#/items","instanceLocation":"#/0","valid":false,
"errors":[{"keyword":"https://json-schema.org/keyword/type","absoluteKeywordLocation":"http://example.com/schemas/string#/items/type","instanceLocation":"#/0","valid":false,"errors":[]}]}]}

My code

image

What I am looking for is a descriptive error similar to what cfworker/json-schema throws

Items did not match schema. Instance type "number" is invalid. Expected "string".

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions