/Knowledge/sources/honojs__hono/llms-full/validation-manual-validator--0480029e27e4.md
Validation: Manual validator - hono-docs
Validation: Manual validator Source evidence: /Sources/honojs hono/provenance.md Canonical citation: https://hono.dev/llms full.txt manual validator Summary...
Validation: Manual validator
Source evidence: /Sources/honojs__hono/provenance.md Canonical citation: https://hono.dev/llms-full.txt#manual-validator
Summary
First, introduce a way to validate incoming values without using the third-party Validator. Import validator from hono/validator. ts import { validator } from 'hono/validator' To validate form data, specify form as the first...
Content
First, introduce a way to validate incoming values without using the third-party Validator.
Import validator from hono/validator.
import { validator } from 'hono/validator'
To validate form data, specify form as the first argument and a callback as the second argument.
In the callback, validates the value and return the validated values at the end.
The validator can be used as middleware.
app.post(
'/posts',
validator('form', (value, c) => {
const body = value['body']
if (!body || typeof body !== 'string') {
return c.text('Invalid!', 400)
}
return {
body: body,
}
}),
//...
Within the handler, you can get the validated value with c.req.valid('form').
, (c) => {
const { body } = c.req.valid('form')
// ... do something
return c.json(
{
message: 'Created!',
},
201
)
}
Metadata
{
"chunk_index": 0,
"citation": "https://hono.dev/llms-full.txt#manual-validator",
"coverage_role": "overview",
"qualified_title": "Hono / llms-full / Validation > Manual validator (1)",
"retrieved_at": "2026-07-02T05:51:01Z",
"section_index": 101,
"source_id": "/honojs/hono",
"source_type": "llms_full",
"target_label": "llms-full",
"title": "Validation: Manual validator",
"upstream_url": "https://hono.dev/llms-full.txt",
"version": "2026"
}