Confispex.Type.Base64Encoded (confispex v1.2.0)
A type for base64 encoded values.
Decodes base64 encoded string.
Options
:of- Type reference for casting decoded value. Can be a module or{module, opts}tuple. Defaults toConfispex.Type.String. The default value isConfispex.Type.String.
Examples
iex> Confispex.Type.cast("aGVsbG8=", Confispex.Type.Base64Encoded)
{:ok, "hello"}
iex> Confispex.Type.cast("//8=", Confispex.Type.Base64Encoded)
{:error, {<<255, 255>>, Confispex.Type.String, [validation: "not a valid string"]}}
iex> Confispex.Type.cast("//8=", {Confispex.Type.Base64Encoded, of: Confispex.Type.Term})
{:ok, <<0xFFFF::16>>}