# `AsyncApiSpex.Validator`
[🔗](https://github.com/jamescarr/ankusa/blob/async_api_spex-v0.2.0/packages/async_api_spex/lib/async_api_spex/validator.ex#L1)

Checks a resolved AsyncAPI document against the rules this library relies on.

`validate/1` resolves the document first, then returns `:ok` or
`{:error, messages}`. Every message names the JSON path it concerns. Rules
checked:

  1. `asyncapi` is `"3.0.0"` and `info` has a non-empty `title` and `version`.
  2. Every server has a non-empty `host` and `protocol`.
  3. Server, channel, operation, channel message, and parameter ids match
     `~r/\A[A-Za-z0-9_-]+\z/`; component schemas and messages match
     `~r/\A[A-Za-z0-9_.-]+\z/`.
  4. A channel's `{name}` address expressions equal its parameter keys; a
     `nil` address has no parameters.
  5. Every channel server reference resolves.
  6. Every operation action is `send` or `receive`, its channel reference
     resolves, and its message references are messages of that channel.
  7. Every component schema and message reference resolves.
  8. Every extension key starts with `x-`.
  9. No component schema contains a module that does not use
     `AsyncApiSpex.Schema` (a typo in a `fields:` type, for example).

# `validate`

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

Validates a document, resolving it first.

---

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