Artefact.Validator (Artefact v0.2.0)

Copy Markdown View Source

Validates %Artefact{} structs against the structural rules documented in Artefact.

Public predicates and validators are surfaced through Artefact itself via defdelegate; this module is the implementation home.

An artefact is valid when:

  • its uuid is a valid UUIDv7
  • :title, :description, :base_label are each nil or a string
  • :graph is %Artefact.Graph{} with list :nodes and :relationships
  • every node has a non-empty string :id, a UUIDv7 :uuid, a list of string :labels, and a map :properties
  • every relationship has a non-empty string :id, a non-empty string :type, :from_id and :to_id referring to extant nodes, and a map :properties
  • node uuids, node ids and relationship ids are unique within the graph

Summary

Functions

Returns true when value is an %Artefact{} struct.

Returns true when value is a valid artefact.

Validate an artefact. Returns :ok or {:error, %Artefact.Error.Invalid{reasons: [...]}}.

Validate an artefact. Returns :ok or raises Artefact.Error.Invalid with the collected reasons.

Functions

is_artefact?(arg1)

Returns true when value is an %Artefact{} struct.

is_valid?(value)

Returns true when value is a valid artefact.

validate(a)

Validate an artefact. Returns :ok or {:error, %Artefact.Error.Invalid{reasons: [...]}}.

:reasons is a list of human-readable strings, one per rule violation, in source order.

validate!(value)

Validate an artefact. Returns :ok or raises Artefact.Error.Invalid with the collected reasons.