Sha256: 4623a907da5c8be77ed97f0a7ce2c6d2f96f201a5a8b8363c6d4b9371c1c56e8
Contents?: true
Size: 1.91 KB
Versions: 15
Compression:
Stored size: 1.91 KB
Contents
require 'json' require 'json-schema' # temporary json-schema patch # waiting for rubygem json-schema patch #require 'adiwg/mdtranslator/readers/sbJson/validator.rb' module ADIWG module Mdtranslator module Readers module SbJson # validate json against the schemas # only one schema version is supported at this time def self.validate(file, responseObj) # begin # schema = ADIWG::SbJsonSchemas::Utils.schema_path # aValErrs = Array.new # if responseObj[:readerValidationLevel] == 'strict' # aValErrs = JSON::Validator.fully_validate(schema, file, :strict => true, :errors_as_objects => true) # elsif responseObj[:readerValidationLevel] == 'normal' # aValErrs = JSON::Validator.fully_validate(schema, file, :errors_as_objects => true) # end # # if aValErrs.length > 0 # responseObj[:readerValidationPass] = false # responseObj[:readerValidationMessages] << 'sbJson schema validation Failed - see following message(s):\n' # responseObj[:readerValidationMessages] << aValErrs # return # end # rescue JSON::Schema::ValidationError # responseObj[:readerValidationPass] = false # responseObj[:readerValidationMessages] << 'sbJson schema validation Failed - see following message(s):\n' # responseObj[:readerValidationMessages] << $!.message # return # end responseObj[:readerValidationPass] = true end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems