Class responsible for validating JSON content before parsing. This should be called from every parsing class.
@author Boris Parak <parak@cesnet.cz>
Shortcuts to interesting methods on logger
Repository constants
Validates given `json` text with the appropriate schema for `type`. This method raises `Occi::Core::Errors::ParsingError` on failure.
@param json [String] JSON text to validate @param type [Symbol] schema selector @raise [Occi::Core::Errors::ParsingError] on validation failure
# File lib/occi/core/parsers/json/validator.rb, line 28 def validate!(json, type) logger.debug "Validating #{json.inspect} as #{type}" if logger_debug? JSON::Validator.schema_reader = JSON::Schema::Reader.new(accept_uri: false, accept_file: true) JSON::Validator.validate!(schema_for(type), json, json: true) rescue JSON::Schema::JsonParseError, JSON::Schema::ValidationError => e raise Occi::Core::Errors::ParsingError, e.message end