SC.Validator.Utils (sc v1.0.2)

View Source

Utility functions shared across validator modules.

Provides common operations like result manipulation, state collection, and document traversal helpers.

Summary

Functions

Add an error to the validation result.

Add a warning to the validation result.

Collect all states from a document, including nested states.

Collect all transitions from a list of states.

Recursively collect states from a state list.

Linear search for a state by ID during validation (before lookup maps are built).

Get the initial state ID from a document.

Check if a state with the given ID exists in the document.

Functions

add_error(result, error)

Add an error to the validation result.

add_warning(result, warning)

Add a warning to the validation result.

collect_all_states(document)

@spec collect_all_states(SC.Document.t()) :: [SC.State.t()]

Collect all states from a document, including nested states.

collect_all_transitions(states)

@spec collect_all_transitions([SC.State.t()]) :: [SC.Transition.t()]

Collect all transitions from a list of states.

collect_states_recursive(states)

@spec collect_states_recursive([SC.State.t()]) :: [SC.State.t()]

Recursively collect states from a state list.

find_state_by_id_linear(state_id, document)

@spec find_state_by_id_linear(String.t(), SC.Document.t()) :: SC.State.t() | nil

Linear search for a state by ID during validation (before lookup maps are built).

get_initial_state(document)

@spec get_initial_state(SC.Document.t()) :: String.t() | nil

Get the initial state ID from a document.

Returns the explicit initial state if set, otherwise the first state's ID, or nil if the document has no states.

state_exists?(state_id, document)

@spec state_exists?(String.t(), SC.Document.t()) :: boolean()

Check if a state with the given ID exists in the document.