class Axlsx::RangeValidator

Validate that the value provided is between a specific range Note that no data conversions will be done for you! Comparisons will be made using < and > or <= and <= when the inclusive parameter is true

Public Class Methods

validate(name, min, max, value, inclusive = true) click to toggle source

@param [String] name The name of what is being validated @param [Any] min The minimum allowed value @param [Any] max The maximum allowed value @param [Any] value The value to be validated @param [Boolean] inclusive Flag indicating if the comparison should be inclusive.

# File lib/axlsx/util/validators.rb, line 26
def self.validate(name, min, max, value, inclusive = true)
  passes = if inclusive
             min <= value && value <= max
           else
             min < value && value < max
           end
  raise ArgumentError, (ERR_RANGE % [value.inspect, min.to_s, max.to_s, inclusive]) unless passes
end