Commit Graph

4 Commits

Author SHA1 Message Date
Betterlol 2a24a26dd5 [Phase 44][feat]: add PipeType for explicit two-stage validation
- New PipeType(Schema, TransformClosure, Schema) for chaining schemas
  with clear stage boundaries via Schema::pipe(output)
- parse_pipe: parse_inner(input) → bridge → parse_inner(output)
- append_rule penetrates PipeType to output (rules after pipe go to
  second stage)
- Exporters render as 'input → output' (prompt), transparent fallthrough
  to output (json_schema), output type (moonbit_struct), .pipe() code gen
- 7 tests: basic chain, stage rejection, transform bridge, chained
  rules after pipe, error_map on second stage
- 531 tests pass, 0 warnings
2026-07-18 14:43:23 +08:00
Betterlol 5532fa61f5 [Phase 43][feat]: add recursive schema and discriminated union
- New SchemaType::LazyType(() -> Schema) for recursive/self-referencing schemas
  via recursive(fn) factory. LazyType resolved at parse time; post-parse rules
  on lazy wrapper checked against original input.
- New SchemaType::DiscriminatedUnionType(String, Map[String, Schema]) for
  O(1) branch dispatch via discriminator field, via discriminated_union()
  factory. Supports MissingRequired/InvalidValue/InvalidType errors.
- All exporters handle both new types: LazyType resolves closure and recurses;
  DiscriminatedUnionType renders as union of options.
- 10 new tests (5 recursive + 5 discriminated_union).
- 523 tests pass, 0 warnings.
2026-07-18 14:24:46 +08:00
Betterlol ab123991ee [Phase 42][fix]: constraint_extractor uses IssueCode; collect_raw_errors takes path_stack
- constraint_extractor now extracts min/max/format/multipleOf/is_int from
  Rule.code (structured IssueCode) instead of only parsing annotation JSON.
  Annotation JSON kept as fallback for Custom rules.
- collect_raw_errors accepts Array[String] path_stack and formats internally,
  removing redundant 'let path = format_path(path_stack)' at all 7 call sites.
- Update test_prompt expectation: nonempty() now correctly shows [min: 1]
  since Its TooSmall code is properly extracted.
2026-07-18 12:02:50 +08:00
Betterlol 5ba5342d39 [Phase 42][feat]: add IssueCode + ErrorMap + ParseParams error system
- Add core/errors.mbt with IssueCode enum (12 variants), ErrorMap type,
  ParseParams, RawIssue, finalize_issue/finalize_issues pipeline
- Add code: IssueCode field to ValidationError and Rule
- Add Schema::safe_parse(self, json, ParseParams) public API
- Messages resolved at error source (no Schema ref in RawIssue)
- Path stored as pre-formatted String (no double allocation)
- All rule methods pass precise IssueCode (InvalidFormat for validators,
  TooBig/TooSmall for bounds, NotMultipleOf, InvalidValue, etc.)
- 34 new tests for issue codes and error map behavior
- All 513 tests pass, 0 warnings
2026-07-18 11:41:40 +08:00