tdegrunt / jsonschema

JSON Schema validation
Other
1.83k stars 262 forks source link

Any way to validate the validation schema? #275

Open i-break-codes opened 5 years ago

i-break-codes commented 5 years ago

For example, consider the following

var a = {
  hello: [1, 2, 3],
  world: "true"
}

And I've the following validation object...

var schema = {
  type: 'object',
  properties: {
    hello: {
      type: 'array'
    },
    world: {
      type: 'strings' //note the error here, it should be string instead of strings..
    }
  }
}

The above happily passes the validation, though, it's an issue with the schema rules. Is there any way to validate the validation object itself?

stevenpetryk commented 4 years ago

I know it's a year later, but you could validate your schema against a JSON schema meta-schema (a schema for schemas).

https://json-schema.org/specification.html#meta-schemas

awwright commented 4 years ago

You can validate against the meta-schema, but there really ought to be a built-in way to ensure the schema is valid, before you start testing values against it. I'll leave this open to track that.