Validators¶
didactic.api.validates ¶
validates(
*field_names: str, mode: str = "after"
) -> Callable[
[Callable[..., FieldValue]], Callable[..., FieldValue]
]
Mark a class method as a Python-side validator for one or more fields.
| PARAMETER | DESCRIPTION |
|---|---|
*field_names
|
Names of the fields this validator applies to. At least one is required.
TYPE:
|
mode
|
Either
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Callable
|
A decorator that tags the wrapped method for the metaclass to register on the field spec. |
Notes
Validators are deliberately not lifted into the Theory; for
cross-language constraints, use __axioms__ or Annotated[T, ...]
metadata instead.
Examples:
didactic.api.ValidationError
dataclass
¶
ValidationError(
entries: tuple[ValidationErrorEntry, ...],
model: type | None = None,
)
Bases: Exception
One or more validation failures, surfaced as a single exception.
didactic collects all failures during construction or mutation and raises them together (no fail-fast). This mirrors Pydantic's behaviour so users who grep "for the list of errors" find one.
| PARAMETER | DESCRIPTION |
|---|---|
entries
|
The individual failures.
TYPE:
|
model
|
The model class that failed validation.
TYPE:
|
See Also
ValidationErrorEntry : the per-issue record.
didactic.api.ValidationErrorEntry
dataclass
¶
ValidationErrorEntry(
loc: tuple[str | int, ...],
type: str,
msg: str,
axiom: str | None = None,
vertex_id: str | None = None,
)
A single validation failure.
| PARAMETER | DESCRIPTION |
|---|---|
loc
|
Path through the schema where the failure was detected, e.g.
TYPE:
|
type
|
Error category. One of
TYPE:
|
msg
|
Human-readable description.
TYPE:
|
axiom
|
The panproto-Expr term that failed, when applicable.
TYPE:
|
vertex_id
|
The schema vertex id where the violation lives, when known.
TYPE:
|