# `JSONSchex.Formats`
[🔗](https://github.com/xinz/jsonschex/blob/main/lib/jsonschex/formats.ex#L1)

Implements validation logic for the 'format' keyword.

## Supported Formats

The following format values are supported when `format_assertion: true` is enabled:

- Date/Time: `date-time`, `date`, `time`, `duration`
- Email: `email`, `idn-email`
- Hostnames: `hostname`, `idn-hostname`
- IP Addresses: `ipv4`, `ipv6`
- URIs: `uri`, `uri-reference`, `iri`, `iri-reference`, `uri-template`
- Identifiers: `uuid`
- JSON Pointers: `json-pointer`, `relative-json-pointer`
- Patterns: `regex`

## Behavior

- Non-string data always passes format validation.
- Unknown format values pass validation by default (per the JSON Schema specification).

# `validate`

Validates data against the specified format.

Non-string data always passes. Unknown format values pass by default.

## Examples

    iex> JSONSchex.Formats.validate("email", "user@example.com")
    :ok

    iex> JSONSchex.Formats.validate("email", "not-an-email")
    {:error, %JSONSchex.Types.ErrorContext{contrast: "email", input: "not-an-email"}}

    iex> JSONSchex.Formats.validate("email", 123)
    :ok

---

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