Sha256: 7eb01e19546b59b20156cd773aed0d96f443f3715adb2e09760ea280d66da4c2

Contents?: true

Size: 761 Bytes

Versions: 3

Compression:

Stored size: 761 Bytes

Contents

require 'json-schema/attribute'

module JSON
  class Schema
    class MaximumAttribute < Attribute
      def self.validate(current_schema, data, fragments, processor, validator, options = {})
        if data.is_a?(Numeric)
          if (current_schema.schema['exclusiveMaximum'] ? data >= current_schema.schema['maximum'] : data > current_schema.schema['maximum'])
            message = "The property '#{build_fragment(fragments)}' did not have a maximum value of #{current_schema.schema['maximum']}, "
            message += current_schema.schema['exclusiveMaximum'] ? 'exclusively' : 'inclusively'
            validation_error(processor, message, fragments, current_schema, self, options[:record_errors])
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
json-schema-2.4.1 lib/json-schema/attributes/maximum.rb
json-schema-2.4.0 lib/json-schema/attributes/maximum.rb
json-schema-2.3.0 lib/json-schema/attributes/maximum.rb