Sha256: dcc849d14e63c3034ee46f6cb42c7ee66909bb6c858e4833378ba9fc6f6d3179

Contents?: true

Size: 561 Bytes

Versions: 3

Compression:

Stored size: 561 Bytes

Contents

require 'json-schema/attribute'

module JSON
  class Schema
    class MaxItemsAttribute < Attribute
      def self.validate(current_schema, data, fragments, processor, validator, options = {})
        if data.is_a?(Array) && (data.compact.size > current_schema.schema['maxItems'])
          message = "The property '#{build_fragment(fragments)}' had more items than the allowed #{current_schema.schema['maxItems']}"
          validation_error(processor, message, fragments, current_schema, self, options[:record_errors])
        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/maxitems.rb
json-schema-2.4.0 lib/json-schema/attributes/maxitems.rb
json-schema-2.3.0 lib/json-schema/attributes/maxitems.rb