# schema/validate Check a value (a plain or tagged map) against a `deftype` schema. Deep and recursive: nested `:Type` fields and `:of` element types are checked too. ## Syntax
[schema/validate $type $value ?opts]
## Parameters - `$type` — a type name (keyword or string), e.g. `:Order` - `$value` — the map to validate - `?opts` — optional options map: - `:coerce true` — apply `:coerce` field conversions before checking - `:defaults true` — fill missing fields from `:default` before checking - `:strict true` — unknown map keys are errors - `:all true` — collect every error instead of stopping at the first ## Examples
deftype Item %{
    :sku %{:type :string :required true :pattern "^[a-z0-9-]+$"}
    :qty %{:type :number :coerce true :min 1}
}

[schema/validate :Item %{:sku "tea" :qty 2}]
# => %Ok{:value %{:sku "tea" :qty 2}}

set bad %{:sku "tea" :qty 0}
set e [schema/validate :Item $bad]
# => %Err{ :path @{:qty} :message "must be >= 1" }

[schema/validate :Item %{:sku "tea" :qty "2"} %{:coerce true}]
# => %Ok{:value ...} — the string qty is accepted under :coerce
## Returns `%Ok{:value <the value>}` when it passes. On failure, `%Err{:path @{...}` :message "..."}` with a vector path of field keywords and integer` indices. With `:all true`, `%Err{:errors @{%{:path ... :message ...} ...}}`. Union-typed fields (`defunion`) dispatch on the value's tag: the value must be one of the variants, and checking continues against the variant's schema (paths name the failing variant field). Validates only — no coercion or typing is written back; use `schema/from-value` to build a `%Type{...}` value. ## See Also `schema/from-value`, `info/props`, `deftype`