Sha256: 7b4b8efd06f9fb76548ccebe376b4260d9c1a97d68ae43174dab9e4aa6b9fd74

Contents?: true

Size: 591 Bytes

Versions: 3

Compression:

Stored size: 591 Bytes

Contents

require 'json-schema/attribute'

module JSON
  class Schema
    class MinLengthAttribute < Attribute
      def self.validate(current_schema, data, fragments, processor, validator, options = {})
        if data.is_a?(String)
          if data.length < current_schema.schema['minLength']
            message = "The property '#{build_fragment(fragments)}' was not of a minimum string length of #{current_schema.schema['minLength']}"
            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/minlength.rb
json-schema-2.4.0 lib/json-schema/attributes/minlength.rb
json-schema-2.3.0 lib/json-schema/attributes/minlength.rb