Spek.Check (Spek v0.2.0)

Copy Markdown View Source

Struct that represents the evaluation result of a single check function.

Summary

Types

Defines the arguments passed to the check function.

t()

Representation of a single policy check.

Types

args()

@type args() :: [{:ctx, atom()} | :ctx | term()]

Defines the arguments passed to the check function.

If the list is empty, the function will be called without arguments.

The list value :ctx is substituted with the evaluation context passed to the evaluation functions.

The list value {:ctx, atom} is substituted with the value at the given key in the evaluation context.

t()

@type t() :: %Spek.Check{
  args: args(),
  fun: atom(),
  module: module(),
  result: Spek.result() | nil,
  satisfied?: boolean() | nil
}

Representation of a single policy check.

  • module, fun, args - Module, function, and arguments for the check function to run. To reference a key in the context argument passed to the eval functions, use {:ctx, atom}. To pass the whole context as an argument, use :ctx.
  • result - The original return value of the check function.
  • satisfied? - A boolean set depending on the return value of the check function.

result and satisfied? are only set when the expression is evaluated.

The result values true, :ok, and {:ok, term} are mapped to satisfied?: true. The result values false, :error, and {:error, term} are mapped to satisfied?: false.