Sha256: 8276b8af89896ee2a6b7a52c260718aa7de4f44cfd4a0bff235818599f70c9ff

Contents?: true

Size: 604 Bytes

Versions: 26

Compression:

Stored size: 604 Bytes

Contents

module JSON
  class Schema
    class MaxDecimalAttribute < Attribute
      def self.validate(current_schema, data, fragments, processor, validator, options = {})
        if data.is_a?(Numeric)
          s = data.to_s.split(".")[1]
          if s && s.length > current_schema.schema['maxDecimal']
            message = "The property '#{build_fragment(fragments)}' had more decimal places than the allowed #{current_schema.schema['maxDecimal']}"
            validation_error(processor, message, fragments, current_schema, self, options[:record_errors])
          end
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
json-schema-2.2.5 lib/json-schema/attributes/maxdecimal.rb
json-schema-2.2.4 lib/json-schema/attributes/maxdecimal.rb
json-schema-2.2.3 lib/json-schema/attributes/maxdecimal.rb
json-schema-2.2.2 lib/json-schema/attributes/maxdecimal.rb
json-schema-2.2.1 lib/json-schema/attributes/maxdecimal.rb
json-schema-1.2.1 lib/json-schema/attributes/maxdecimal.rb
json-schema-2.2.0 lib/json-schema/attributes/maxdecimal.rb
json-schema-1.2.0 lib/json-schema/attributes/maxdecimal.rb
json-schema-2.1.9 lib/json-schema/attributes/maxdecimal.rb
json-schema-2.1.8 lib/json-schema/attributes/maxdecimal.rb
json-schema-2.1.7 lib/json-schema/attributes/maxdecimal.rb
json-schema-2.1.6 lib/json-schema/attributes/maxdecimal.rb
json-schema-2.1.5 lib/json-schema/attributes/maxdecimal.rb
json-schema-2.1.4 lib/json-schema/attributes/maxdecimal.rb
json-schema-2.1.3 lib/json-schema/attributes/maxdecimal.rb
json-schema-2.1.2 lib/json-schema/attributes/maxdecimal.rb
json-schema-2.1.1 lib/json-schema/attributes/maxdecimal.rb
json-schema-2.1.0 lib/json-schema/attributes/maxdecimal.rb
json-schema-2.0.5 lib/json-schema/attributes/maxdecimal.rb
json-schema-2.0.4 lib/json-schema/attributes/maxdecimal.rb