Sha256: fd0d0f45c612e8e1061786a609309a49a8779df654651e235e62b8c9e23791dd
Contents?: true
Size: 1.4 KB
Versions: 5
Compression:
Stored size: 1.4 KB
Contents
# frozen_string_literal: true module Jimmy class Schema # Set the minimum value. # @param [Numeric] number The minimum numeric value. # @param [true, false] exclusive Whether the value is included in the # minimum. # @return [self] self, for chaining def minimum(number, exclusive: false) set_numeric_boundary 'minimum', number, exclusive end # Set the exclusive minimum value. # @param [Numeric] number The exclusive minimum numeric value. # @return [self] self, for chaining def exclusive_minimum(number) minimum number, exclusive: true end # Set the maximum value. # @param [Numeric] number The maximum numeric value. # @param [true, false] exclusive Whether the value is included in the # maximum. # @return [self] self, for chaining def maximum(number, exclusive: false) set_numeric_boundary 'maximum', number, exclusive end # Set the exclusive maximum value. # @param [Numeric] number The exclusive maximum numeric value. # @return [self] self, for chaining def exclusive_maximum(number) maximum number, exclusive: true end private def set_numeric_boundary(name, number, exclusive) valid_for 'number', 'integer' assert_numeric number assert_boolean exclusive name = 'exclusive' + name[0].upcase + name[1..] if exclusive set name => number end end end
Version data entries
5 entries across 5 versions & 1 rubygems