v0.6.0
Added
- Field annotations of the form
A | Bwhere bothAandBareTaggedUnionroots are now classified as a multi-root discriminated union. The two arms must share the same discriminator field name (checked at class-creation time) and their discriminator-value sets must be disjoint (checked lazily, only on encode/decode of an actually colliding value, so a model whose union-typed field is never encoded with a colliding variant remains usable). Encode and decode both consult the live merged variant registry, so variants registered after the field's parent class is classified participate fully. (#30) @dx.model_validator(mode="after")decorates a class method as a class-level validator that receives the constructed instance and runs after every per-field validator and every__axioms__check.raise ValueError/raise TypeErrorfrom the body surfaces as aValidationErrorentry withtype="validator_error"and emptyloc. Multiple model validators on one class collect into a single error. Subclass inheritance and the silent-shadow override-without-marker policy work the same as for@validates. Use this for cross-field invariants that aren't expressible in the__axioms__surface syntax. The shape mirrors Pydantic v2's@model_validator(mode="after"). (#31)
Fixed
- The axiom evaluator now resolves
length xs(panproto's long-form length builtin) the same aslen xs. Both compile to Pythonlen(...). (#31) isNone/isNull/isSome/isJustbuiltins resolve to the obviousvalue is None/value is not Nonepredicates in axiom expressions. The Python-friendlyis null/is not nullpreprocessor rules from v0.5.1 already covered the most common spelling; these add the explicit-call form for axioms that prefer it. (#31)
Changed
docs/guide/unions.mddocuments the union-of-TaggedUnion-roots shape with the disjoint-values requirement spelled out.docs/guide/validators.mddocuments@dx.model_validatorand the cross-field-invariants decision tree (axiom for surface-syntax expressible, model_validator for Python-needed).
Full changelog: https://github.com/panproto/didactic/blob/main/CHANGELOG.md