Statifier.Validator.Checks.Targets (Statifier v2.0.0)

Copy Markdown View Source

Check 2 (spec 3.5): every <transition>'s target id resolves to a state in the document. Walks Context.transitions - every owner (:plain, :initial, :history) in one traversal - and reports {:unresolved_target, id} per unresolved id, at that transition's own target span (falling back to the transition's own span when unwritten).

This check owns target existence for every transition in the document ("one rule, one owner"): later checks that also walk transition targets (checks 3 and 5) must not re-report an id this check already reported unresolved. They do not need anything extra from Context to honor that - "unresolved" and "absent from Context.states" are the same fact, so a plain Map.has_key?(context.states, id) lookup is exactly the skip test those checks need.

Summary

Functions

Returns an :unresolved_target error for every <transition> in the document (plain, <initial>, and <history> default alike) whose target id does not resolve to a state in Context.states. Owns target existence for the whole document, so later checks may treat an id this check already reported as already handled rather than re-reporting it. Returns [] when every transition target resolves.

Functions

check(document, context)

@spec check(
  document :: Statifier.Document.t(),
  context :: Statifier.Validator.Context.t()
) :: [
  Statifier.Validator.Error.t()
]

Returns an :unresolved_target error for every <transition> in the document (plain, <initial>, and <history> default alike) whose target id does not resolve to a state in Context.states. Owns target existence for the whole document, so later checks may treat an id this check already reported as already handled rather than re-reporting it. Returns [] when every transition target resolves.