lib/adiwg/mdtranslator/readers/mdJson/mdJson_validator.rb in adiwg-mdtranslator-2.0.0rc11 vs lib/adiwg/mdtranslator/readers/mdJson/mdJson_validator.rb in adiwg-mdtranslator-2.0.0rc13
- old
+ new
@@ -15,45 +15,45 @@
require 'json'
require 'json-schema'
require 'adiwg-mdjson_schemas'
module ADIWG
- module Mdtranslator
- module Readers
- module MdJson
+ module Mdtranslator
+ module Readers
+ module MdJson
- # validate json against the adiwg-json_schemas
- # only a single schema version is supported at this time
- def self.validate(file, responseObj)
+ # validate json against the adiwg-json_schemas
+ # only a single schema version is supported at this time
+ def self.validate(file, responseObj)
- bStrict = false
- if responseObj[:readerValidationLevel] == 'strict'
- bStrict = true
- end
- ADIWG::MdjsonSchemas::Utils.load_schemas(false)
+ bStrict = false
+ if responseObj[:readerValidationLevel] == 'strict'
+ bStrict = true
+ end
+ ADIWG::MdjsonSchemas::Utils.load_schemas(false)
- begin
- aErrors = []
- aErrors = JSON::Validator.fully_validate('schema.json', file, :strict=>bStrict)
+ begin
+ aErrors = []
+ aErrors = JSON::Validator.fully_validate('schema.json', file, :strict => bStrict)
- if aErrors.length > 0
- responseObj[:readerValidationPass] = false
- responseObj[:readerValidationMessages] << 'mdJson schema validation Failed - see following message(s):\n'
- responseObj[:readerValidationMessages] << aErrors
- return
- end
+ if aErrors.length > 0
+ responseObj[:readerValidationPass] = false
+ responseObj[:readerValidationMessages] << 'mdJson schema validation Failed - see following message(s):\n'
+ responseObj[:readerValidationMessages] << aErrors
+ return
+ end
- rescue JSON::Schema::ValidationError
- responseObj[:readerValidationPass] = false
- responseObj[:readerValidationMessages] << 'mdJson schema validation Failed - see following message(s):\n'
- responseObj[:readerValidationMessages] << $!.message
- return
- end
+ rescue JSON::Schema::ValidationError
+ responseObj[:readerValidationPass] = false
+ responseObj[:readerValidationMessages] << 'mdJson schema validation Failed - see following message(s):\n'
+ responseObj[:readerValidationMessages] << $!.message
+ return
+ end
- end
-
end
- end
- end
+
+ end
+ end
+ end
end