Cannot self-validate the schema
The spec says that the schema is self validating, but when I try using your library, I get this error:
JSON::Schema::ValueError: dependencies is missing and it is not optional
/Library/Ruby/Gems/1.8/gems/jsonschema-2.0.0/lib/jsonschema.rb:40:in `check_property'
/Library/Ruby/Gems/1.8/gems/jsonschema-2.0.0/lib/jsonschema.rb:209:in `check_object'
/Library/Ruby/Gems/1.8/gems/jsonschema-2.0.0/lib/jsonschema.rb:207:in `each'
/Library/Ruby/Gems/1.8/gems/jsonschema-2.0.0/lib/jsonschema.rb:207:in `check_object'
/Library/Ruby/Gems/1.8/gems/jsonschema-2.0.0/lib/jsonschema.rb:99:in `check_property'
/Library/Ruby/Gems/1.8/gems/jsonschema-2.0.0/lib/jsonschema.rb:287:in `validate'
/Library/Ruby/Gems/1.8/gems/jsonschema-2.0.0/lib/jsonschema.rb:298:in `validate'
./sqapp.rb:96:in `POST /d/schemas/add'
This library is in accordance with JSON Schema 2nd Draft ( http://groups.google.com/group/json-schema/web/json-schema-proposal---second-draft ), excepting Extending and Referencing / unique property.
Thanks for your report.
Are you planning to update to draft 3, which replaces the "optional" attribute with "required" attribute (and makes optional the default)?
I would like to implement draft 3 JSON Schema in the future. but, JSON Schema draft 3 is very complexed (such as format, URI based $schema, etc.), so this takes a little long time...
thx.
If interested, I have a fairly stable draft-3 compliant Ruby json schema validator at https://github.com/hoxworth/json-schema. The validator also supports draft-1 and draft-2, and will be tracking any future updates to the JSON Schema spec.
Oh! Thanks!!! Your implementation is great!
Do you think about the 3rd draft complicated attributes like "regexp" in "format", "$ref" with the external URL(http://...)?
The $ref attribute is definitely handled and resolves against absolute and relative URIs. The library will load external 'http' and 'file' URI schemes if the URI is not explicitly defined in the schema, and will treat all other URIs as internal references.
As for format, the library does not explicitly enforce that the instance value matches the constraints of a format. The draft spec explicitly states that validators are not required to enforce these rules and that the 'format' attribute is to be used mostly as an inference tool by consumers of data that adhere to a JSON schema.
There are probably a few more things that need to be ironed out in this library; however it is pretty simple to add / remove features and declare new schemas. I will be moving the library into its first major release once the JSON schema is finalized past the draft stage and proper testing has been performed.
Oh thanks!
The draft spec explicitly states that validators are not required to enforce these rules and that the 'format' attribute is to be used mostly as an inference tool by consumers of data that adhere to a JSON schema.
Oh! I overlooked. I misunderstood that JSON Schema spec requires completely implementation of "format".