# `Threadline.Evidence.Subject`
[🔗](https://github.com/szTheory/threadline/blob/v1.2.0/lib/threadline/evidence/subject.ex#L1)

The closed set of subject names accepted by Threadline evidence records.

Use `supported_subjects/0` to inspect the names, `validate/1` to check a
subject or descriptor, and `supported?/1` when a boolean result is enough.

# `subject_descriptor`

```elixir
@type subject_descriptor() ::
  atom()
  | String.t()
  | %{
      optional(:subject) =&gt; atom() | String.t() | subject_descriptor(),
      optional(:name) =&gt; atom() | String.t() | subject_descriptor()
    }
  | %{optional(String.t()) =&gt; atom() | String.t() | subject_descriptor()}
```

A subject name or descriptor. Recognized keys, in precedence order, are atom `:subject`, atom
`:name`, string `"subject"`, and string `"name"`. Each recognized value may be an atom, string,
or another descriptor, and nested recognized descriptors are normalized recursively. Key
precedence applies at each nested level; unknown-only maps remain unchanged as unsupported
values.

When a recognized key is present, other keys are ignored. If a map has no recognized key, it is
returned unchanged as the unsupported value. The string-key map arm also represents extra keys
and mixed atom/string maps.

# `subject_input`

```elixir
@type subject_input() ::
  atom()
  | bitstring()
  | number()
  | %{optional(subject_input()) =&gt; subject_input()}
  | tuple()
  | list()
  | pid()
  | port()
  | reference()
  | function()
```

Any value accepted by the subject validator and predicate.

# `supported?`

```elixir
@spec supported?(subject_input()) :: boolean()
```

Returns `true` when a subject or subject descriptor is supported, and `false` for every other
input.

# `supported_subjects`

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

Returns the six subject names accepted by Evidence record writers.

# `validate`

```elixir
@spec validate(subject_input()) :: :ok | {:error, {:unsupported_subject, term()}}
```

Returns `:ok` for a supported subject or `{:error, {:unsupported_subject, value}}` otherwise.

The unsupported value is the normalized subject for recognized descriptors and the original
input for values that cannot be normalized. The inventory is closed to `supported_subjects/0`.

---

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