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

Pure Elixir options validator to replace NimbleOptions.

Provides schema-based validation with support for common types,
default values, and custom validation rules.

# `option_config`

```elixir
@type option_config() :: keyword()
```

# `schema_option`

```elixir
@type schema_option() :: {atom(), option_config()}
```

# `t`

```elixir
@type t() :: %ToonEx.Options.Validator{
  __exception__: true,
  key: atom(),
  message: String.t(),
  value: term()
}
```

# `validation_result`

```elixir
@type validation_result() :: {:ok, keyword()} | {:error, t()}
```

# `message`

Returns a human-readable error message.

# `validate`

```elixir
@spec validate(
  keyword(),
  [schema_option()]
) :: validation_result()
```

Validates options against a schema.

## Schema Configuration

Each option in the schema supports:
  * `:type` - Type specification (see supported types below)
  * `:default` - Default value if option is not provided
  * `:required` - Whether the option is required (default: false)
  * `:doc` - Documentation string (ignored during validation)

## Supported Types

  * `:any` - Any value
  * `:boolean` - `true` or `false`
  * `:atom` - Any atom
  * `:string` - Binary string
  * `:integer` - Any integer
  * `:pos_integer` - Positive integer (> 0)
  * `:non_neg_integer` - Non-negative integer (>= 0)
  * `:float` - Float number
  * `:number` - Integer or float
  * `:keyword` - Keyword list
  * `:list` - List
  * `:map` - Map
  * `{:in, values}` - Value must be in the given list
  * `{:or, types}` - Value must match one of the given types
  * `{:custom, fun}` - Custom validation function

## Examples

    schema = [
      name: [type: :string, required: true],
      age: [type: :pos_integer, default: 0],
      role: [type: {:in, [:admin, :user]}, default: :user]
    ]

    ToonEx.Options.Validator.validate([name: "Alice"], schema)
    # => {:ok, [name: "Alice", age: 0, role: :user]}

    ToonEx.Options.Validator.validate([age: -1], schema)
    # => {:error, %ToonEx.Options.Validator{key: :name, ...}}

---

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