Class: EnvValidator::Types::Integer

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

Instance Method Summary collapse

Instance Method Details

#coerce(value) ⇒ Object



36
37
38
# File 'lib/env_validator/types.rb', line 36

def coerce(value)
  Integer(value)
end

#validate(value) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/env_validator/types.rb', line 28

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