ToonEx.Decode.Options (toon_ex v1.0.0)

Copy Markdown View Source

Validation and normalization of decoding options.

Summary

Functions

Returns the options schema.

Validates and normalizes decoding options.

Validates and normalizes decoding options, raising on error.

Functions

schema()

@spec schema() :: keyword()

Returns the options schema.

validate(opts)

@spec validate(keyword()) :: {:ok, map()} | {:error, ToonEx.Options.Validator.t()}

Validates and normalizes decoding options.

Examples

iex> ToonEx.Decode.Options.validate([])
{:ok, %{keys: :strings, strict: true, indent_size: 2}}

iex> ToonEx.Decode.Options.validate(keys: :atoms)
{:ok, %{keys: :atoms, strict: true, indent_size: 2}}

iex> match?({:error, _}, ToonEx.Decode.Options.validate(keys: :invalid))
true

validate!(opts)

@spec validate!(keyword()) :: map()

Validates and normalizes decoding options, raising on error.