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.0.3 lib/json-schema/attributes/maxdecimal.rb
json-schema-2.0.2 lib/json-schema/attributes/maxdecimal.rb
json-schema-2.0.1 lib/json-schema/attributes/maxdecimal.rb
json-schema-2.0.0 lib/json-schema/attributes/maxdecimal.rb
json-schema-1.1.1 lib/json-schema/attributes/maxdecimal.rb
json-schema-1.1.0 lib/json-schema/attributes/maxdecimal.rb