# `JSONSchex.Draft202012.Dialect`
[🔗](https://github.com/xinz/jsonschex/blob/main/lib/jsonschex/draft202012/dialect.ex#L1)

Draft 2020-12 dialect helpers for built-in dialect recognition and
`$vocabulary` resolution.

This module centralizes the Draft 2020-12-specific pieces that were previously
embedded in the generic compiler flow:

- recognition of the canonical Draft 2020-12 meta-schema URI
- default active vocabularies for the built-in Draft 2020-12 dialect
- extraction of enabled vocabularies from a meta-schema's `$vocabulary`
- validation of required vocabularies against the implementation capability set
- built-in dialect resolution for compiler delegation

It is intentionally small and data-oriented so generic compiler code can
delegate draft-specific decisions here.

## Examples

    iex> JSONSchex.Draft202012.Dialect.builtin_schema_uri()
    "https://json-schema.org/draft/2020-12/schema"

    iex> JSONSchex.Draft202012.Dialect.builtin_schema?(%{"$schema" => "https://json-schema.org/draft/2020-12/schema"})
    true

    iex> JSONSchex.Draft202012.Dialect.enabled_vocabularies(%{
    ...>   "$vocabulary" => %{
    ...>     "https://json-schema.org/draft/2020-12/vocab/core" => true,
    ...>     "https://json-schema.org/draft/2020-12/vocab/format-annotation" => false
    ...>   }
    ...> })
    ["https://json-schema.org/draft/2020-12/vocab/core",
     "https://json-schema.org/draft/2020-12/vocab/format-annotation"]

    iex> JSONSchex.Draft202012.Dialect.resolve_builtin(%{"$schema" => "https://json-schema.org/draft/2020-12/schema"})
    {:ok,
     ["https://json-schema.org/draft/2020-12/vocab/core",
      "https://json-schema.org/draft/2020-12/vocab/applicator",
      "https://json-schema.org/draft/2020-12/vocab/validation",
      "https://json-schema.org/draft/2020-12/vocab/unevaluated",
      "https://json-schema.org/draft/2020-12/vocab/format-annotation",
      "https://json-schema.org/draft/2020-12/vocab/content",
      "https://json-schema.org/draft/2020-12/vocab/meta-data"]}

    iex> JSONSchex.Draft202012.Dialect.resolve_builtin(%{"$schema" => "https://example.com/custom"})
    nil

# `base_uri`

```elixir
@spec base_uri() :: String.t()
```

Returns the canonical base URI for Draft 2020-12 resources.

# `builtin_schema?`

```elixir
@spec builtin_schema?(map()) :: boolean()
```

Returns `true` when the given schema declares the canonical built-in
Draft 2020-12 meta-schema URI.

# `builtin_schema_uri`

```elixir
@spec builtin_schema_uri() :: String.t()
```

Returns the canonical built-in Draft 2020-12 meta-schema URI.

# `default_active_vocabularies`

```elixir
@spec default_active_vocabularies() :: [String.t()]
```

Returns the default active vocabularies for the built-in Draft 2020-12
dialect.

This excludes `format-assertion`, matching the standard Draft 2020-12
behavior.

# `enabled_vocabularies`

```elixir
@spec enabled_vocabularies(map(), [String.t()]) :: [String.t()]
```

Returns the enabled vocabularies for a schema.

If the schema declares `$vocabulary`, required vocabularies are always
included, and optional vocabularies are included only when they are supported
by the implementation. If `$vocabulary` is absent, the provided defaults are
returned unchanged.

# `resolve_builtin`

```elixir
@spec resolve_builtin(map()) :: {:ok, [String.t()]} | nil
```

Resolves the built-in Draft 2020-12 dialect for a schema.

Returns `{:ok, vocabularies}` when the schema declares the canonical built-in
Draft 2020-12 meta-schema URI, otherwise returns `nil`.

# `supported_vocabularies`

```elixir
@spec supported_vocabularies() :: [String.t()]
```

Returns the full set of vocabularies supported by the implementation for
Draft 2020-12 vocabulary validation.

# `validate_required_vocabularies`

```elixir
@spec validate_required_vocabularies(map()) ::
  :ok | {:error, JSONSchex.Types.Error.t()}
```

Validates that all required vocabularies declared by the schema are supported.

Returns `:ok` when valid, otherwise returns a structured
`:unsupported_vocabulary` error.

# `vocabulary_supported?`

```elixir
@spec vocabulary_supported?(String.t()) :: boolean()
```

Returns `true` if the given vocabulary URI is supported by the implementation.

---

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