Arcadic.Identifier (Arcadic v0.7.1)

Copy Markdown View Source

Allowlist validation for identifiers arcadic places into a URL path or a statement (database names, labels, property names).

Values are never identifiers — they ride the params map. This guards the identifier surface only (AGENTS.md Critical Rule 2). A failure carries the invalid-SHAPE fact only, never the offending string (it may be attacker- controlled or contain a secret).

Summary

Functions

Boolean form of validate/1.

Returns :ok for a valid identifier, {:error, :invalid_identifier} otherwise.

Validates a server/database setting KEY (dotted allowlist); value-free.

Validates a URL for interpolation into an IMPORT/BACKUP/restore command. Positive RFC-3986 allowlist + scheme allowlist (http/https/file); value-free reasons.

Functions

valid?(value)

@spec valid?(term()) :: boolean()

Boolean form of validate/1.

validate(value)

@spec validate(term()) :: :ok | {:error, :invalid_identifier}

Returns :ok for a valid identifier, {:error, :invalid_identifier} otherwise.

Examples

iex> Arcadic.Identifier.validate("Person")
:ok
iex> Arcadic.Identifier.validate("1bad")
{:error, :invalid_identifier}

validate_setting_key(key)

@spec validate_setting_key(term()) :: :ok | {:error, :invalid_setting_key}

Validates a server/database setting KEY (dotted allowlist); value-free.

validate_url(url)

@spec validate_url(term()) ::
  :ok
  | {:error,
     :empty
     | :too_long
     | :invalid_chars
     | :invalid_scheme
     | :invalid_uri
     | :not_a_string}

Validates a URL for interpolation into an IMPORT/BACKUP/restore command. Positive RFC-3986 allowlist + scheme allowlist (http/https/file); value-free reasons.