Concord.Validation (Concord v3.0.0)

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.

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.