Sha256: 37d22de0bfa80205de28b2686eee0748dd2b325d317b683cc9bd5d4a94e78f8e

Contents?: true

Size: 493 Bytes

Versions: 15

Compression:

Stored size: 493 Bytes

Contents

module JSON
  class Schema
    class MinItemsAttribute < Attribute
      def self.validate(current_schema, data, fragments, validator, options = {})
        if data.is_a?(Array) && (data.compact.size < current_schema.schema['minItems'])
          message = "The property '#{build_fragment(fragments)}' did not contain a minimum number of items #{current_schema.schema['minItems']}"
          raise ValidationError.new(message, fragments, current_schema)
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
json-schema-0.9.12 lib/json-schema/attributes/minitems.rb
json-schema-0.9.11 lib/json-schema/attributes/minitems.rb
json-schema-0.9.10 lib/json-schema/attributes/minitems.rb
json-schema-0.9.9 lib/json-schema/attributes/minitems.rb
json-schema-0.9.8 lib/json-schema/attributes/minitems.rb
json-schema-0.9.7 lib/json-schema/attributes/minitems.rb
json-schema-0.9.6 lib/json-schema/attributes/minitems.rb
json-schema-0.9.5 lib/json-schema/attributes/minitems.rb
json-schema-0.9.4 lib/json-schema/attributes/minitems.rb
json-schema-0.9.3 lib/json-schema/attributes/minitems.rb
json-schema-0.9.2 lib/json-schema/attributes/minitems.rb
json-schema-0.9.1 lib/json-schema/attributes/minitems.rb
json-schema-0.9.0 lib/json-schema/attributes/minitems.rb
json-schema-0.2.0 lib/json-schema/attributes/minitems.rb
json-schema-0.1.14 lib/json-schema/attributes/minitems.rb