Method: Axlsx::DataTypeValidator.validate
- Defined in:
- lib/axlsx/util/validators.rb
.validate(name, types, v, other = false) ⇒ Boolean
Perform validation
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/axlsx/util/validators.rb', line 54 def self.validate(name, types, v, other=false) if other.is_a?(Proc) raise ArgumentError, (ERR_TYPE % [v.inspect, name, types.inspect]) unless other.call(v) end v_class = v.is_a?(Class) ? v : v.class Array(types).each do |t| return if v_class <= t end raise ArgumentError, (ERR_TYPE % [v.inspect, name, types.inspect]) end |