0.4.1 • Published 8 months ago

@hono/valibot-validator v0.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months 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.4.1

8 months ago

0.4.0

9 months ago

0.3.1

9 months ago

0.3.0

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago