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
26 27 28 29 30 31 32 33 |
# 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 |