class SaraSchema::Validator
Public Class Methods
validate(schema, to_be_validated)
click to toggle source
# File lib/sara-schema/validator.rb, line 13 def validate(schema, to_be_validated) JSONSchemer.schema(path(schema)).valid?(to_be_validated) end
validate!(schema, to_be_validated)
click to toggle source
# File lib/sara-schema/validator.rb, line 17 def validate!(schema, to_be_validated) JSONSchemer.schema(path(schema)).validate(to_be_validated) end
Private Class Methods
path(schema)
click to toggle source
# File lib/sara-schema/validator.rb, line 23 def path(schema) file = "#{RESOURCES}/#{schema}.json" # rubocop:disable Metrics/LineLength # rubocop:disable Style/IfUnlessModifier raise SaraSchema::Validator::SchemaNotFoundError, "#{schema} is not a supported schema" unless File.file?(file) # rubocop:enable Style/IfUnlessModifier # rubocop:enable Metrics/LineLength Pathname.new(file) end