aeat.application.wizard._widgets module¶
Per-widget validators and the canonical dispatch entry point.
The schema-driven wizard collects answers as canonical-token strings.
Each WizardWidget member dispatches onto one validator that
parses the raw token, enforces the closed-set or filesystem
constraints declared on the descriptor, and returns the canonical
form. Validators raise WizardValidationError whose message
carries the failing question’s translation key so renderers can map
the failure back to a localised prompt.
Tax-ID-shaped questions (any question whose id matches tax-id or
ends with -tax-id) route through
aeat.core.identity.validate_identity() so the Spanish NIF / NIE
/ CIF checksum is enforced at every write surface: interactive,
--quiet flag, and profile wizard mutations.
- validate_text(raw, question)[source]¶
Return the trimmed text answer; reject blank required strings.
Tax-id-shaped questions additionally route through the Spanish NIF / NIE / CIF checksum validator from
aeat.core.identity. Malformed values raiseWizardValidationErrorcarryingwizard.errors.invalid_tax_id. The validator’s resolved, localised diagnostic — which names the correct check letter or the expected document shape — is interpolated asdetailso the operator sees an actionable one-step fix rather than an opaque refusal.The
address-postcodequestion additionally enforces the Spanish 5-digit postcode format (province code 01-52 followed by three digits). The answer stays a string throughout so leading zeros are preserved; it is never int-coerced.- Return type:
- Parameters:
raw (str)
question (WizardQuestion)
- validate_secret(raw, question)[source]¶
Return the raw secret answer unchanged; reject blank required strings.
- Return type:
- Parameters:
raw (str)
question (WizardQuestion)
- validate_confirm(raw, question)[source]¶
Canonicalise a boolean answer to
"true"/"false".Blank-answer policy mirrors
validate_select(): a blank token is accepted for an optional question or for a conditionally-gated question (one that declaresvisible_when) and returns the empty canonical, representing the undeclared three-state. The persistence layer drops blank values, so an optional CONFIRM that the operator never positively declared persists nothing and the typed projection reloads asNonerather than collapsing onto declared-False. A blank answer fails only for an unconditionally-required CONFIRM.- Return type:
- Parameters:
raw (str)
question (WizardQuestion)
- validate_select(raw, question)[source]¶
Reject any answer that is not declared in the question’s choices.
Blank-answer policy is keyed on the static descriptor, because the validator is handed only the question and the raw answer — the runner’s evaluated
visible_whenverdict is not threaded into this call. A blank answer fails only for an unconditionally required question (requiredand novisible_when). A blank answer is accepted for an optional question, and for a conditionally-gated question (one that declares avisible_when) regardless of itsrequiredflag — a gated question represents an undeclared closed-set fact when left blank. Any non-blank answer must match a declared choice.- Return type:
- Parameters:
raw (str)
question (WizardQuestion)
- validate_checkbox(raw, question)[source]¶
Validate a comma-separated list of choice tokens against the choices.
Blank-answer policy matches
validate_select(): an empty token set fails only for an unconditionally required question (requiredand novisible_when). An empty set is accepted for an optional question, and for a conditionally-gated question (one that declares avisible_when) regardless of itsrequiredflag, because the runner’s evaluated visibility is not threaded into this validator. Every supplied token must match a declared choice; the canonical form is the sorted token set.- Return type:
- Parameters:
raw (str)
question (WizardQuestion)
- validate_path(raw, question)[source]¶
Return the canonical filesystem string; reject blank required paths.
- Return type:
- Parameters:
raw (str)
question (WizardQuestion)
- validate_integer(raw, question)[source]¶
Parse the answer as an integer and re-emit the canonical decimal form.
- Return type:
- Parameters:
raw (str)
question (WizardQuestion)
- validate_widget_answer(question, raw)[source]¶
Dispatch
question.widgetonto its widget-specific validator.- Return type:
- Parameters:
question (WizardQuestion)
raw (str)