cadrumo.domain.filing.validator module¶
Cross-cutting validator for domain.filing drafts.
The validator is intentionally pure: it consumes a draft + the
casilla collection it was built against and returns a tuple of
ModeloValidationFinding records. It never raises — strict
behaviour is the caller’s responsibility via
fail_on_warning on build_draft().
This is draft-construction-time structural validation, and it is one
stage inside the pre-file verification gate rather than an alternative to
it. build_draft() runs this validator on every draft it constructs
and stamps the result onto the findings tuple of the resulting
ModeloDraft, so the stage is reached from all three operator
verbs that build a draft: verify and file via the revision workflow
gate, and export via the draft-export action.
The workflow engine then re-scans those stamped findings in its
VALIDATING_DRAFT stage and aborts on any ERROR-severity row.
The two finding vocabularies are deliberately distinct and answer
different questions. ModeloValidationFinding answers “is this
draft structurally well-formed against the casilla collection?” —
schema version, declared and required casillas, value ranges, formula
traces, and the deadline check — and grounds itself in Manual práctico
rule ids via references_rules. The verify gate’s
ModeloVerificationFinding answers the broader operator-facing
readiness question, carries a closed kind/severity taxonomy, and
requires registry legal_refs provenance. Neither model subsumes the
other; do not collapse them.
See also
verify_modelo_revision():The pre-file verification gate this validator runs inside, which owns
ModeloVerificationFindingand the persistedVerificationReport.
- class ModeloValidator(*, schema_provider, deadline_checker=None)[source]¶
Bases:
objectApply cross-cutting validation rules to a
ModeloDraft.The validator depends on Protocols, not concrete subpackages, so alternative casilla, formula, or deadline implementations can be supplied without touching the validator.
- Parameters:
schema_provider (CasillaSchemaProvider)
deadline_checker (DeadlineChecker | None)
- validate(draft)[source]¶
Run every validation rule against
draft.- Parameters:
draft (
ModeloDraft) – TheModeloDraftto validate.- Return type:
- Returns:
A tuple of
ModeloValidationFindingitems, possibly empty.
- apply_validation(draft, findings)[source]¶
Return a
ModeloDraftcopy ofdraftwithfindingsand a fresh status.Status promotion logic:
Any
ERROR→ModeloDraftStatus.BORRADOR(still blocking).Any
WARNINGonly →ModeloDraftStatus.VALIDADO.No findings →
ModeloDraftStatus.LISTO_PARA_PRESENTAR.
- Return type:
- Parameters:
draft (ModeloDraft)
findings (tuple[ModeloValidationFinding, ...])
- derive_validation_status(findings)[source]¶
Return the machine validation status implied by
findings.- Return type:
- Returns:
The
ModeloDraftStatusderived from the severity of the findings.- Parameters:
findings (tuple[ModeloValidationFinding, ...])