Repository navigation
Open
Labels
P3EventuallyEventuallycodegenCode generationCode generationenhancementNew feature or requestNew feature or request
Description
Validators are checked at comline build but never run: no generator reads @validators. The design is already written up in docs/design/validators.md ("Phase 4 — runtime enforcement"). This issue tracks building it.
Steps (from the design note)
- 4a.
Freeze theDone in feat!: structured types and literals in the frozen IR #108.validate { assert(...) }condition as a treeFrozenUnit::Assertnow carriesexpr: Condition: a flatfirstcomparison plusrest: Vec<(LogicalOp, Comparison)>, grouped left to right because the grammar has no precedence. The operands arePath/Integer/String. The text andreferencesare kept alongside. - 4b. Done for Rust (comline-rust#52, runtime#12, generation#57). Generated types implement
comline_runtime::validation::Validate(validate()collects,validate_first()stops at one).fieldis the path to the value (friends[1],author.handle), and checks recurse into nested structs and array elements. Resolution, including alias chains and property binding, lives incomline_codegen::validation. - 4c. Done for Rust (cli#71).
validate_on_decode = "off" | "collect" | "first", defaultoff. Structs and errors decode through an unchecked shadow via#[serde(try_from)]; the dispatcher refuses a call whose params fail their checks. - 4d. comline-typescript; validators declared in another schema or package (needs that schema's IR at generate time).
Points the design note doesn't settle yet
Settled in core#109: Unicode scalar values for a string, elements for an array. 4d's TypeScript must count by code point. Rust'svalue.lengthmust mean the same thing in every target..chars().count()counts Unicode scalar values, but TypeScript's.lengthcounts UTF-16 code units ("😀".length == 2), so the same schema would accept different strings. Core defines it (see Validators declare the types they apply to #97) and each generator emits code that matches (in TS, iterate by code point).- Generated checks must be panic-safe: a failing condition is a validation failure, never a crash.
- Function arguments: comline-rust already bundles them into a
<Protocol><Method>Paramsstruct, sovalidate()can run there once arguments can carry validators (only via aliases, Validators on type aliases #99).
The design note should be updated as these land.
Metadata
Metadata
Assignees
Labels
P3EventuallyEventuallycodegenCode generationCode generationenhancementNew feature or requestNew feature or request
Type
Projects
- StatusShow more project fieldsIn Progress
Activity
[-]Run validators in generated code (validators phase 4)[/-][+]Run validators in generated code: TypeScript and cross-schema validators (phase 4d)[/+]Kinflou commentedon Nov 9, 2026
Retitled to what's left. Steps 4a–4c are done for Rust. Step 4d remains: the TypeScript generator (generation's FEATURES.md lists
validatorsandvalidate_on_decodeas ignored there), and validators declared in another schema or package.