Sha256: 3b244cb5cd11ca7a68125c45bb65c3468005130a2fddf148661de2bc17eac241

Contents?: true

Size: 551 Bytes

Versions: 11

Compression:

Stored size: 551 Bytes

Contents

require 'json-schema/attribute'

module JSON
  class Schema
    class ConstAttribute < Attribute
      def self.validate(current_schema, data, fragments, processor, validator, options = {})
        const_value = current_schema.schema['const']
        unless const_value == data
          message = "The property '#{build_fragment(fragments)}' value #{data.inspect} did not match constant '#{const_value}'"
          validation_error(processor, message, fragments, current_schema, self, options[:record_errors])
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
json-schema-5.1.1 lib/json-schema/attributes/const.rb
json-schema-5.1.0 lib/json-schema/attributes/const.rb
json-schema-5.0.1 lib/json-schema/attributes/const.rb
json-schema-5.0.0 lib/json-schema/attributes/const.rb
json-schema-4.3.1 lib/json-schema/attributes/const.rb
json-schema-4.3.0 lib/json-schema/attributes/const.rb
json-schema-4.2.0 lib/json-schema/attributes/const.rb
json-schema-4.1.1 lib/json-schema/attributes/const.rb
json-schema-4.1.0 lib/json-schema/attributes/const.rb
json-schema-4.0.0 lib/json-schema/attributes/const.rb
json-schema-3.0.0 lib/json-schema/attributes/const.rb