Class: Axlsx::RangeValidator
- Inherits:
-
Object
- Object
- Axlsx::RangeValidator
- Defined in:
- lib/axlsx/util/validators.rb
Overview
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
Class Method Summary collapse
Class Method Details
.validate(name, min, max, value, inclusive = true) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/axlsx/util/validators.rb', line 28 def self.validate(name, min, max, value, inclusive = true) passes = if inclusive min <= value && value <= max else min < value && value < max end raise ArgumentError, format(ERR_RANGE, value.inspect, min.to_s, max.to_s, inclusive) unless passes end |