Sha256: 491410135c6dcf77f7e88f9c8e5eb6b5ea480acac2854a6381c32f7fafbf0d5d

Contents?: true

Size: 569 Bytes

Versions: 4

Compression:

Stored size: 569 Bytes

Contents

require 'json-schema/attribute'

module JSON
  class Schema
    class UniqueItemsAttribute < Attribute
      def self.validate(current_schema, data, fragments, processor, validator, options = {})
        return unless data.is_a?(Array)

        if data.clone.uniq!
          message = "The property '#{build_fragment(fragments)}' contained duplicated array values"
          validation_error(processor, message, fragments, current_schema, self, options[:record_errors])
        end
      end

      def self.validate_on_false?
        false
      end
    end
  end
end

Version data entries

4 entries across 3 versions & 2 rubygems

Version Path
json-schema-ouidou-2.9.1 lib/json-schema/attributes/uniqueitems.rb
json-schema-ouidou-2.9.0 lib/json-schema/attributes/uniqueitems.rb
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/bundler/gems/json-schema-2253a5ee6679/lib/json-schema/attributes/uniqueitems.rb
mountapi-0.11.1 vendor/json-schema/lib/json-schema/attributes/uniqueitems.rb