Confispex.Type.Base64Encoded (confispex v1.1.0)
A type for base64 encoded values.
Decodes base64 encoded string.
Options
:of
-Confispex.Type.String
is used by default. Other types can be used as well according toConfispex.Type.type_reference/0
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>>}