Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returns "valid" when schema is invalid #81

Closed
windlass opened this issue Sep 26, 2013 · 1 comment
Closed

Returns "valid" when schema is invalid #81

windlass opened this issue Sep 26, 2013 · 1 comment

Comments

@windlass
Copy link

This doesn't seem right:

schema = { "type" => "object", "properties" => { "test" => "string" } }
data = { "test" => "foo" }
JSON::Validator.validate!(schema, data)
=> true

The example is an invalid schema, obviously. It should be:

schema = { "type" => "object", "properties" => { "test" => { "type" => "string" } } }

I tried several other schemata I know to be invalid, such as:

schema = { "type" => "unknown" }

and got the same result.

Shouldn't the correct behavior be to raise an exception when the schema is invalid, or at least return false? This is the behavior of libXML in the XML space, and is also the behavior of several Python implementations of JSON schema.

I plan to investigate this and submit a fix, but wanted to raise the issue first in case this is actually the desired behavior, and if so, ask why.

@windlass
Copy link
Author

windlass commented Oct 4, 2013

I just re-read the documentation and found out about the :validate_schema parameter. Everything is as it should be.

Sorry for the noise. Closing this issue.

@windlass windlass closed this as completed Oct 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant