Browse Source

can't find jsonspec

pull/76/head
magicmilo 3 years ago
parent
commit
6c272dad87
  1. 13
      app/helpers/json_schema_validation.rb

13
app/helpers/json_schema_validation.rb

@ -23,9 +23,10 @@ require "json"
# } # }
# } # }
# }, # },
begin
schema = { schema = {
"$schema": "https://json-schema.org/draft/2020-12/schema", "$schema": "https://json-schema.org/draft-04/schema#",
"$id": "https://example.com/product.schema.json", "$id": "https://example.com/product.schema.json",
"title": "Form", "title": "Form",
"description": "A form", "description": "A form",
@ -54,13 +55,13 @@ schema = {
} }
} }
} }
} }
begin
# file = File.open("config/forms/2021_2022.json") # file = File.open("config/forms/2021_2022.json")
file = File.open("spec/fixtures/forms/test_validator.json") file = File.open("spec/fixtures/forms/test_validator.json")
data = JSON.parse(file.read) puts data = JSON.parse(file.read)
puts JSON::Validator.validate(schema, data)
if JSON::Validator.validate!(schema, data) if JSON::Validator.validate!(schema, data)
puts "Success" puts "Success"

Loading…
Cancel
Save