Sha256: d883fcd7b8d48b90e97b2daa57f851ba76460fba62fe99332fe312b749deb4ee

Contents?: true

Size: 705 Bytes

Versions: 9

Compression:

Stored size: 705 Bytes

Contents

module JSON
  class Schema
    class MaximumAttribute < Attribute
      def self.validate(current_schema, data, fragments, 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(message, fragments, current_schema, self, options[:record_errors])
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
json-schema-1.0.12 lib/json-schema/attributes/maximum.rb
json-schema-1.0.11 lib/json-schema/attributes/maximum.rb
json-schema-1.0.10 lib/json-schema/attributes/maximum.rb
json-schema-1.0.9 lib/json-schema/attributes/maximum.rb
json-schema-1.0.8 lib/json-schema/attributes/maximum.rb
json-schema-1.0.7 lib/json-schema/attributes/maximum.rb
json-schema-1.0.6 lib/json-schema/attributes/maximum.rb
json-schema-1.0.5 lib/json-schema/attributes/maximum.rb
json-schema-1.0.4 lib/json-schema/attributes/maximum.rb