Class: EnvValidator::Types::Json
- Defined in:
- lib/env_validator/types.rb
Instance Method Summary collapse
Instance Method Details
#coerce(value) ⇒ Object
114 115 116 |
# File 'lib/env_validator/types.rb', line 114 def coerce(value) JSON.parse(value.to_s) end |
#validate(value) ⇒ Object
107 108 109 110 111 112 |
# File 'lib/env_validator/types.rb', line 107 def validate(value) JSON.parse(value.to_s) true rescue JSON::ParserError raise TypeError, "Expected valid JSON, got #{value.inspect}" end |