AuditLog.Actor (AuditLog v0.3.1)

Copy Markdown View Source

Represents a durable snapshot of the person or service responsible for an event.

Actor types and identifiers are application-owned codes stored as text. A label is an optional display snapshot, such as the email address an operator would have recognised when the event occurred. No field is a foreign key to a mutable application record.

Summary

Functions

Validates an application-owned actor type and identifier.

Validates an actor and returns it, or raises AuditLog.InvalidValueError.

Types

t()

@type t() :: %AuditLog.Actor{
  id: String.t(),
  label: String.t() | nil,
  type: String.t()
}

Functions

new(type, id, opts \\ [])

@spec new(term(), term(), keyword()) ::
  {:ok, t()} | {:error, AuditLog.InvalidValueError.t()}

Validates an application-owned actor type and identifier.

type, id, and the optional :label must implement String.Chars. new/3 converts the values to strings and trims them. The required type and ID must not be blank.

Example

AuditLog.Actor.new("user", 42, label: "ada@example.com")

new!(type, id, opts \\ [])

@spec new!(term(), term(), keyword()) :: t()

Validates an actor and returns it, or raises AuditLog.InvalidValueError.

Use this function only when invalid input is exceptional. Use new/3 for runtime data that the caller can reject.