Sha256: 48b1cbb71ef41befca46ea56a905fc3ca0937a462abf883fd473b697d0c5e5e3

Contents?: true

Size: 591 Bytes

Versions: 3

Compression:

Stored size: 591 Bytes

Contents

require 'json-schema/attribute'

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