Created
October 25, 2014 18:25
-
-
Save pd/0a6dabe535d0e2ceeb69 to your computer and use it in GitHub Desktop.
Reproducing hoxworth/json-schema issue #96
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/hoxworth/json-schema/issues/96 | |
require 'json-schema' | |
schema = { | |
:type => :object, | |
:required => [ | |
:id, | |
:name, | |
:real_name, | |
:role, | |
:website, | |
:biography, | |
:created_at, | |
:demographic | |
], | |
:properties => { | |
:id => { | |
:type => [ | |
:integer | |
] | |
}, | |
:name => { | |
:type => [ | |
:string | |
] | |
}, | |
:real_name => { | |
:type => [ | |
:string | |
] | |
}, | |
:role => { | |
:type => [ | |
:string | |
] | |
}, | |
:website => { | |
:type => [ | |
:string, | |
:null | |
] | |
}, | |
:created_at => { | |
:type => [ | |
:string | |
] | |
}, | |
:biography => { | |
:type => [ | |
:string, | |
:null | |
] | |
} | |
}, | |
:relationships => { | |
:demographic => { | |
:type => :object, | |
:required => [ | |
:id, | |
:gender | |
], | |
:properties => { | |
:id => { | |
:type => [ | |
:integer | |
] | |
}, | |
:gender => { | |
:type => [ | |
:string | |
] | |
} | |
} | |
} | |
} | |
} | |
obj = '{ | |
"created_at": "2014-01-25T00:58:33-08:00", | |
"id": "8c51eebb719a430091a34021ca49003a", | |
"name": "chelsey", | |
"real_name": "Mekhi Hegmann", | |
"website": null, | |
"role": "user", | |
"biography": null, | |
"demographic": null | |
}' | |
JSON::Validator.validate!(schema, obj, validate_schema: true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment