-
Notifications
You must be signed in to change notification settings - Fork 191
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
fix(valibot-validator): Fix response query types on RPC #914
Conversation
🦋 Changeset detectedLatest commit: 72ce1ce The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
if (!result.success) { | ||
return c.json(result, 400) | ||
if (!parsed.success) { | ||
return c.json({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests fail. If you change these lines like them, it is fixed. Is it OK?
if (!parsed.success) {
return c.json(parsed, 400)
}
Hi @ajotaos Can you add a test like this? diff --git a/packages/valibot-validator/test/index.test.ts b/packages/valibot-validator/test/index.test.ts
index d50fd78..2c16d76 100644
--- a/packages/valibot-validator/test/index.test.ts
+++ b/packages/valibot-validator/test/index.test.ts
@@ -324,3 +324,28 @@ describe('With Hook Async', () => {
expect(res.status).toBe(400)
})
})
+
+describe('Test types', () => {
+ it('Should return correct types when validating a query', () => {
+ const app = new Hono()
+
+ const routes = app.post(
+ '/',
+ vValidator(
+ 'query',
+ object({
+ foo: string(),
+ })
+ ),
+ (c) => {
+ return c.json(c.req.valid('query'))
+ }
+ )
+
+ type T = ExtractSchema<typeof routes>
+
+ type Actual = T['/']['$post']['input']['query']
+ type Expected = { foo: string }
+ type verify = Expect<Equal<Expected, Actual>>
+ })
+}) |
Hi @yusukebe, sorry for the delay on this update. Had already gone home for the holidays. The changes you suggested were added. Thank you about it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thanks! Looks good to me. I'll merge it and release a new version. |
This middleware addresses #899.