Skip to content

validation

validation #

Construction-time validation of a node's inputs, substeps, and settings.

Called once from Procedure.__post_init__ so an ill-typed DAG fails where it is built, with a message that names the field. The checks mirror the field roles ([.fields][]):

  • inputs must be procedures whose return type structurally matches the field's Input[T]Array[Image] and ImageSequence interchange; an Input[Path] accepts any Path (the precise target is checked by the navigation node itself); a bare/TypeVar input accepts any CGType.
  • substeps must each be a Procedure.
  • settings must match their Setting[T] at runtime (a backstop under the static check), handling unions, list[...], and type[...].

validate(node) #

Type-check every field of node against its annotation; raise on mismatch.

Source code in capturegraph-lib/capturegraph/procedures/procedure/type_checking/validation.py
def validate(
    node: Procedure[Any],
) -> None:
    """Type-check every field of ``node`` against its annotation; raise on mismatch."""
    for name, role, annotation in field_roles(type(node)):
        value = getattr(node, name, None)
        if role is FieldRole.INPUT:
            _validate_input(node, name, annotation, value)
        elif role is FieldRole.SUBSTEPS:
            _validate_substeps(node, name, value)
        elif role is FieldRole.SETTING:
            _validate_setting(node, name, annotation, value)