Skip to content

feat(builder): aggregate validation errors in StreamBuilder (#631) - #691

Open
ZacLou wants to merge 1 commit into
conduit-protocol:mainfrom
ZacLou:feat/stream-builder-aggregate-validation-631
Open

feat(builder): aggregate validation errors in StreamBuilder (#631)#691
ZacLou wants to merge 1 commit into
conduit-protocol:mainfrom
ZacLou:feat/stream-builder-aggregate-validation-631

Conversation

@ZacLou

@ZacLou ZacLou commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Closes #631.

Summary

Instead of failing on the first invalid field, StreamBuilder now collects every problem and throws one ValidationError with a .issues[] array.

Changes

  • Added ValidationError class (src/errors.ts) with a frozen issues[] array
  • Modified all StreamBuilder setters to record issues instead of throwing immediately
  • Missing-required-fields check now feeds into the same aggregated list
  • _issues is reset after each failed build() so a fixed builder can be retried
  • Added tests covering multi-field aggregation, issue reset, and happy path

Example

try {
  builder.token("bad").sender("").amount(-1).build();
} catch (err) {
  if (err instanceof ValidationError) {
    console.log(err.issues);
    // ["token must be...", "sender must be...", "amount must be..."]
  }
}

…protocol#631)

- Add ValidationError class with a frozen  array
- Modify all StreamBuilder setters to record issues instead of throwing immediately
- Collect missing-required-fields check into the same issue list
- Throw one ValidationError at build() time with every problem surfaced
- Reset  after each failed build so retrying a fixed builder works
- Add tests covering multi-field aggregation, issue reset, and happy path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StreamBuilder: aggregate validation errors

1 participant