Absurd.Name (absurd v0.2.1)

Copy Markdown View Source

Validation for names persisted by the Absurd protocol.

Queue names follow the upstream SQL rule: they may contain any characters, including whitespace, but must not be empty and must fit in 57 UTF-8 bytes. Task, step, and event names must contain at least one non-whitespace character.

Examples

iex> Absurd.Name.validate_queue("Queue Name-1")
{:ok, "Queue Name-1"}

iex> match?({:error, %Absurd.Error{kind: :validation}}, Absurd.Name.validate_queue(String.duplicate("é", 29)))
true

iex> Absurd.Name.validate_durable("send-email", :task)
{:ok, "send-email"}

Summary

Functions

Returns the maximum encoded byte length accepted for queue names.

Validates a task, step, or event name without changing it.

Validates a queue name without changing it.

Functions

max_queue_bytes()

@spec max_queue_bytes() :: pos_integer()

Returns the maximum encoded byte length accepted for queue names.

validate_durable(name, field)

@spec validate_durable(term(), :task | :step | :event) ::
  {:ok, String.t()} | {:error, Absurd.Error.t()}

Validates a task, step, or event name without changing it.

The field identifies the value in a returned validation error.

validate_queue(name)

@spec validate_queue(term()) :: {:ok, String.t()} | {:error, Absurd.Error.t()}

Validates a queue name without changing it.

Whitespace-only queue names are valid because upstream deliberately delegates the character set to PostgreSQL's quoted-identifier rules.