Skip to content

osrlib.core.validation

Structured rejection reasons returned by pure validators.

Kernel validators (class choice, the ability adjustment step, purchase and equip legality) return lists of Rejection values rather than raising: an illegal choice is an in-fiction refusal, not a programmer error. Session command rejections carry these values verbatim in the CommandResult envelope.

Calling an apply-step with input its validator rejects — applying an illegal adjustment, equipping forbidden armour — is programmer misuse and raises stdlib ValueError, per the errors convention in osrlib.errors.

Rejection

Bases: BaseModel

A structured reason a validator refused an input.

code is dotted snake_case namespaced by subsystem, like event message codes (creation.class.requirements_not_met, items.equip.armour_forbidden). params carries the structured facts a front end needs to render the refusal — never baked English prose.

code instance-attribute

code: str

params class-attribute instance-attribute

params: dict[str, int | str | tuple[int | str, ...]] = {}