Skip to content

Pretty printing validation errors#113

Merged
xvw merged 3 commits intoxhtmlboi:mainfrom
Linda-Njau:pp_validation_error
Jan 2, 2026
Merged

Pretty printing validation errors#113
xvw merged 3 commits intoxhtmlboi:mainfrom
Linda-Njau:pp_validation_error

Conversation

@Linda-Njau
Copy link
Copy Markdown
Contributor

This PR refactors the validation error pretty printer to make validation failures easier to read. This is a presentation-only change, validation behavior remains the same.

Previously, validation errors were printed as record-like structures. Once errors became nested (for example, records inside lists), the output was hard to follow and made it difficult to see what actually went wrong.

The main change is breaking validation errors into clearer sections. Errors are separated from the given data, and nested errors are presented in a way that makes the structure easier to follow.

For example, an invalid list error now looks like:

Invalid list:
  Errors (3):
  1) At index 0:
    Invalid shape:
      Expected: string
      Given: `1`

  2) At index 1:
    Invalid record:
      Errors (1):
      1) Missing field `name`

  3) At index 2:
    Invalid shape:
      Expected: string
      Given: `3`

  Given list:
    [0] = `1`
    [1] = `{"title": 2}`
    [2] = `3`
    [3] = `"ok"`

There are also a few smaller changes, such as rewording messages, explicitly counting and numbering errors, and other formatting improvements.

TBD: validation errors currently only display the entity name; I’m still working on including the file path in the error message.

@xvw xvw requested review from gr-im and xhtmlboi December 31, 2025 15:39
@xvw
Copy link
Copy Markdown
Collaborator

xvw commented Dec 31, 2025

So cool ! Thanks a lot @Linda-Njau

TBD: validation errors currently only display the entity name; I’m still working on including the file path in the error message.

Would you prefer that we split the review into several PRs, to introduce the file into another PR? And merge it as soon as possible?

@Linda-Njau
Copy link
Copy Markdown
Contributor Author

So cool ! Thanks a lot @Linda-Njau

Thanks!

Would you prefer that we split the review into several PRs, to introduce the file into another PR? And merge it as soon as possible?

yes, I think that works great

Copy link
Copy Markdown
Collaborator

@gr-im gr-im left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool ! I approve!
I think that it deserve a change entry!

@Linda-Njau
Copy link
Copy Markdown
Contributor Author

Cool ! I approve!

Thanks!

I think that it deserve a change entry!

Sure, I’ll do that

@xvw xvw merged commit 4def7a9 into xhtmlboi:main Jan 2, 2026
2 of 4 checks passed
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.

3 participants