Nice Job, and big thanks for getting this out so quick! I've updated
my schemas to the new spec, and am validating with JSV's new 03 env.
I do have a question about JSV's handling of $refs. It seems to me
like you can get a false positive validation when the $ref can't be
resolved. Below is a simple example. The instance is no doubt invalid.
The code asks JSV to validate twice, once before the createSchema
call, and once after. The first call to validate returns no errors,
while the second validate returns errors as expected.
Is this expected behavior?
var schemaWithReference = {
"type":"object",
"properties": {
"child": {"$ref":"./child.json"}
}
};
var referencedSchema = {
"type":"object",
"additionalProperties":false,
"properties": {
"name":{"type":"string"}
}
};
var instance = {
child: {
name:"a name",
invalid:"invalid 'cause additionalProperties is false"
}
};
var JSV = require('lib/jsv').JSV;
var validator = JSV.createEnvironment("json-schema-draft-03");
var report = validator.validate(instance,schemaWithReference);
dumpReport( report );
validator.createSchema(referencedSchema, null, "./child.json");
report = validator.validate(instance,schemaWithReference);
dumpReport( report );