# `Cldr.Message.V2.Nif`
[🔗](https://github.com/elixir-cldr/cldr_messages/blob/v2.0.1/lib/cldr/messages/v2/nif.ex#L1)

NIF wrapper for ICU4C MessageFormat 2.0.

Provides `validate/1` and `format/3` functions that delegate to
ICU's MessageFormatter implementation. The NIF is optional — when
unavailable, `available?/0` returns `false` and calls raise
`:nif_library_not_loaded`.

# `available?`

```elixir
@spec available?() :: boolean()
```

Returns `true` if the MF2 NIF is loaded and available.

# `format`

```elixir
@spec format(String.t(), String.t(), map()) ::
  {:ok, String.t()} | {:error, String.t()}
```

Formats a MessageFormat 2 message string using ICU.

Arguments are passed as a map of `%{name => value}` and
encoded to JSON for the NIF.

Returns `{:ok, formatted_string}` or `{:error, reason}`.

# `validate`

```elixir
@spec validate(String.t()) :: {:ok, String.t()} | {:error, String.t()}
```

Validates a MessageFormat 2 message string using ICU's parser.

Returns `{:ok, normalized_pattern}` or `{:error, reason}`.

---

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