Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(effect-validator): use array formatting for errors #718

Merged
merged 3 commits into from
Oct 2, 2024

Conversation

kyshx
Copy link
Contributor

@kyshx kyshx commented Aug 27, 2024

@effect/schema uses TreeFormatter as the default way of formatting errors. (more here)

The result is hard to read in an http 400 response (although it is really nice in a terminal):

{
  "success": false,
  "error": {
    "_id": "ParseError",
    "message": "{ readonly name: string; readonly password: string; readonly email: a string matching the pattern ^(?!\\.)(?!.*\\.\\.)([A-Z0-9_+-.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9-]*\\.)+[A-Z]{2,}$ }\n└─ [\"password\"]\n   └─ is missing"
  }
}

With the ArrayFormatter it us much better:

{
  "success": false,
  "error": [
    {
      "_tag": "Missing",
      "path": [
        "password"
      ],
      "message": "is missing"
    }
  ]
}

What are your thoughts about this ?

Copy link

changeset-bot bot commented Aug 27, 2024

🦋 Changeset detected

Latest commit: 6d6725c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hono/effect-validator Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@yusukebe
Copy link
Member

@gunta Can you review this?

@kyshx
Copy link
Contributor Author

kyshx commented Sep 26, 2024

@yusukebe It seems like @gunta is not very active lately, can someone else review this ? Maybe @tim-smart or @mikearnaldi from the Effect team.

@yusukebe
Copy link
Member

yusukebe commented Oct 2, 2024

Hi @shokiw

I've added tests, and it looks good. I'll merge this now and release a new version. Thank you!

@yusukebe yusukebe merged commit 80da4aa into honojs:main Oct 2, 2024
1 check passed
@github-actions github-actions bot mentioned this pull request Oct 2, 2024
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.

2 participants