Skip to content
Myr

fix(validator): support async validator func (#1303)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* fix(validator): support async validator func * denoify

authored by Yusuke Wada · committed by GitHub · parent 85f8ab6 · Browse files · 3 files+37 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+37 added−6 removed

  • tests:+25 added−0 removed
  • other:+12 added−6 removed

3 files+37 added−6 removed

modified:deno_dist/validator/validator.ts+6 added-3 removed
modified:src/validator/validator.test.ts+25 added
627 unmodified lines
628 expect(res.status).toBe(200)629 })630 })631})632633describe('Async validator function', () => {634 const app = new Hono()635636 app.get(637 '/posts',638 validator('query', async () => {639 return {640 page: '1',641 }642 }),643 (c) => {644 const { page } = c.req.valid('query')645 return c.json({ page })646 }647 )648649 it('Should get the values from the async function', async () => {650 const res = await app.request('/posts')651 expect(res.status).toBe(200)652 expect(await res.json()).toEqual({653 page: '1',654 })655 })656})
modified:src/validator/validator.ts+6 added-3 removed