Package Exports
- @hono/valibot-validator
- @hono/valibot-validator/dist/cjs/index.js
- @hono/valibot-validator/dist/esm/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@hono/valibot-validator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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