Sha256: cb3bc1bb49c43b5f79e7f2887e299991deca7fdeb53d7712145536598fd16c51
Contents?: true
Size: 833 Bytes
Versions: 6
Compression:
Stored size: 833 Bytes
Contents
module SoberSwag module Reporting module Input ## # Adds the multipleOf constraint to input types. # Will use the '%' operator to calculate this, which may behave oddly for floats. class MultipleOf < Base def initialize(input, mult) @input = input @mult = mult end ## # @return [Interface] attr_reader :input ## # @return [Numeric] attr_reader :mult def call(value) parsed = input.call(value) return parsed if parsed.is_a?(Report::Base) return Report::Value.new(["was not a multiple of #{mult}"]) unless (parsed % mult).zero? parsed end def swagger_schema modify_schema(input, { multipleOf: mult }) end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems