# `AccessGrid.Params`
[🔗](https://github.com/Access-Grid/accessgrid-ex/blob/main/lib/access_grid/params.ex#L1)

Helpers for composing SDK request params. Currently just `require/2` for
client-side required-field presence checks — used internally by `Console`
and `AccessPasses` create/action functions to surface "you forgot X" without
a round-trip to the API.

# `require`

```elixir
@spec require(map(), [atom()]) :: :ok | {:error, :missing_required, [atom(), ...]}
```

Returns `:ok` if every atom key in `required_keys` has a non-blank value
in `params`. Returns `{:error, :missing_required, missing}` where `missing`
is the non-empty list of every missing/blank key (in input order —
deterministic).

"Blank" means `nil`, key absent, an empty string `""`, or a whitespace-only
string (`"   "`, `"\t\n"`, etc.). Empty lists, maps, and other values pass
through — the server validates whether an empty collection is acceptable
for a given field (e.g. Rails rejects `subscribed_events: []` with its own
clear 422 message).

Atom-keyed maps only; mirrors the SDK's input convention.

## Examples

    iex> AccessGrid.Params.require(%{name: "X", protocol: "desfire"}, [:name, :protocol])
    :ok

    iex> AccessGrid.Params.require(%{name: "X"}, [:name, :protocol])
    {:error, :missing_required, [:protocol]}

    iex> AccessGrid.Params.require(%{}, [:name, :platform, :protocol])
    {:error, :missing_required, [:name, :platform, :protocol]}

    iex> AccessGrid.Params.require(%{name: "  "}, [:name])
    {:error, :missing_required, [:name]}

# `require_present`

```elixir
@spec require_present(any(), atom()) ::
  :ok | {:error, :missing_required, [atom(), ...]}
```

Returns `:ok` if `value` is non-blank. Returns
`{:error, :missing_required, [name]}` otherwise (single-element list for
shape consistency with `require/2`). Used to validate positional arguments
(path-segment IDs like `template_id`, `card_id`, etc.) where the SDK
function takes a positional string rather than a key in a params map.

## Examples

    iex> AccessGrid.Params.require_present("tpl_abc", :template_id)
    :ok

    iex> AccessGrid.Params.require_present(nil, :template_id)
    {:error, :missing_required, [:template_id]}

    iex> AccessGrid.Params.require_present("  ", :template_id)
    {:error, :missing_required, [:template_id]}

---

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