JSV v3.3 - Draft-03 Support!

65 views
Skip to first unread message

Gary Court

unread,
Nov 26, 2010, 2:47:59 PM11/26/10
to JSON Schema
It's here!

With the recent publication of the latest JSON Schema specification, I
am proud to announce the release of JSV v3.3 - the first JSON
validator with full draft-03 compliance! This release also brings
along some new features:

* A new environment (json-schema-draft-03) that fully implements the
3rd JSON Schema draft.
* This new environment also includes the schemas from the previous
drafts, under versioned URIs; this allows you to mix and validate
schemas written to different specifications without side-effects.
* All schemas are backwards compatible (where possible) with their
previous versions; this allows you to validate an older schema with
the draft-03 core/hyper schema.
* Backwards compatibility can be disabled by enabling "strict" mode.
* A whole new updated set of unit tests for ensuring validator
correctness.
* Some small performance improvements.

Without a doubt, this latest release of the JSON Schema is a HUGE leap
forward for the specification. As such, these new features makes tools
such as JSV that much more powerful and useful.

As always, you can download the latest release of JSV from:

http://github.com/garycourt/JSV

Thanks! and Enjoy!

Trolly Rogers

unread,
Nov 30, 2010, 8:19:05 AM11/30/10
to JSON Schema
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 );

Gary Court

unread,
Nov 30, 2010, 11:11:13 AM11/30/10
to json-...@googlegroups.com
You bring up a good point; right now JSV ignores references it can't
resolve, but perhaps it should record that as an error instead.
Problem is that links are resolved at schema creation time, not
validation time; meaning that I don't have a report object to record
to. I could throw an exception, but that seem rather invasive.

I'll have to think about how to do this, but thanks for bringing it up.

-Gary

Reply all
Reply to author
Forward
0 new messages