# `ToonEx.Encode.Options`
[🔗](https://github.com/ohhi-vn/toon_ex/blob/v1.1.0/lib/toon_ex/encode/options.ex#L1)

Validation and normalization of encoding options.

# `validated`

```elixir
@type validated() :: %{
  indent: pos_integer(),
  delimiter: String.t(),
  length_marker: String.t() | nil,
  key_order: term(),
  indent_string: String.t()
}
```

Validated encoding options

# `schema`

```elixir
@spec schema() :: keyword()
```

Returns the options schema.

# `validate`

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

Validates and normalizes encoding options.

## Examples

    iex> ToonEx.Encode.Options.validate([])
    {:ok, %{indent: 2, delimiter: ",", length_marker: nil, indent_string: "  "}}

    iex> ToonEx.Encode.Options.validate(indent: 4, delimiter: "\t")
    {:ok, %{indent: 4, delimiter: "\t", length_marker: nil, indent_string: "    "}}

    iex> match?({:error, _}, ToonEx.Encode.Options.validate(indent: -1))
    true

    iex> match?({:error, _}, ToonEx.Encode.Options.validate(delimiter: "invalid"))
    true

# `validate!`

```elixir
@spec validate!(keyword()) :: validated()
```

Validates and normalizes encoding options, raising on error.

## Examples

    iex> ToonEx.Encode.Options.validate!([])
    %{indent: 2, delimiter: ",", length_marker: nil, indent_string: "  "}

    iex> ToonEx.Encode.Options.validate!(indent: 4)
    %{indent: 4, delimiter: ",", length_marker: nil, indent_string: "    "}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
