Class: EnvValidator::Types::Base64

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

Instance Method Summary collapse

Instance Method Details

#coerce(value) ⇒ Object



128
129
130
# File 'lib/env_validator/types.rb', line 128

def coerce(value)
  ::Base64.strict_decode64(value.to_s)
end

#validate(value) ⇒ Object



120
121
122
123
124
125
126
# File 'lib/env_validator/types.rb', line 120

def validate(value)
  # Check if it's valid base64
  ::Base64.strict_decode64(value.to_s)
  true
rescue ArgumentError
  raise TypeError, "Expected valid Base64 string, got #{value.inspect}"
end