Class: EnvValidator::Types::Float

Inherits:
Base
  • Object
show all
Defined in:
lib/env_validator/types.rb

Instance Method Summary collapse

Instance Method Details

#coerce(value) ⇒ Object



50
51
52
# File 'lib/env_validator/types.rb', line 50

def coerce(value)
  Float(value)
end

#validate(value) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/env_validator/types.rb', line 42

def validate(value)
  # Try to convert to float
  Float(value)
  true
rescue ArgumentError
  raise TypeError, "Expected float, got #{value.inspect}"
end