Concord.Validation (Concord v3.0.2)

Copy Markdown View Source

Recursive validation for replicated command safety.

Walks any Elixir term to ensure it contains no anonymous functions, PIDs, ports, or references — values that break deterministic serialization. Also enforces depth and size limits.

Summary

Functions

Validates a Concord key against the configured byte-size limit.

Walks a term recursively, rejecting non-serializable values.

Validates a transaction spec before replicated submission.

Validates a logical value before optional compression.

Functions

validate_key(key)

@spec validate_key(term()) ::
  :ok | {:error, :empty_key | :key_too_large | :invalid_key}

Validates a Concord key against the configured byte-size limit.

The default maximum is 4096 bytes and can be changed with config :concord, kv: [max_key_bytes: bytes].

validate_term(term, max_depth \\ 100)

@spec validate_term(term(), non_neg_integer()) :: :ok | {:error, atom()}

Walks a term recursively, rejecting non-serializable values.

Returns :ok or {:error, reason}.

validate_txn_spec(spec)

@spec validate_txn_spec(map()) :: :ok | {:error, {:invalid_txn, atom()}}

Validates a transaction spec before replicated submission.

Checks structural correctness, limit compliance, and recursive safety.

validate_value(value)

@spec validate_value(term()) :: :ok | {:error, atom()}

Validates a logical value before optional compression.

The configured :max_value_bytes is a local admission cap. It may lower, but never raise, the immutable version-one protocol maximum. Size is measured from the logical Erlang term, so compression settings cannot alter whether the value is admitted.