0.2.4 • Published 4 days ago

@hono/valibot-validator v0.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
4 days ago

Valibot validator middleware for Hono

The validator middleware using Valibot for Hono applications. You can write a schema with Valibot and validate the incoming values.

Usage

import { number, object, string } from 'valibot'
import { vValidator } from '@hono/valibot-validator'

const schema = object({
  name: string(),
  age: number(),
})

app.post('/author', vValidator('json', schema), (c) => {
  const data = c.req.valid('json')
  return c.json({
    success: true,
    message: `${data.name} is ${data.age}`,
  })
})

Hook:

app.post(
  '/post',
  vValidator('json', schema, (result, c) => {
    if (!result.success) {
      return c.text('Invalid!', 400)
    }
  })
  //...
)

Author

Nico Franke https://github.com/ZerNico

License

MIT

0.2.4

4 days ago

0.2.3

19 days ago

0.2.2

3 months ago

0.2.1

6 months ago

0.2.0

9 months ago

0.1.2

9 months ago

0.1.1

9 months ago

0.1.0

9 months ago