🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

@hono/standard-validator

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hono/standard-validator

Validator middleware using Standard Schema

latest
Source
npmnpm
Version
0.2.2
Version published
Weekly downloads
209K
1.86%
Maintainers
1
Weekly downloads
 
Created
Source

Standard Schema validator middleware for Hono

codecov

The validator middleware using Standard Schema Spec for Hono applications. You can write a schema with any validation library supporting Standard Schema and validate the incoming values.

Usage

Basic:

import { z } from 'zod'
import { sValidator } from '@hono/standard-validator'

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

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

Hook:

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

Headers:

Headers are internally transformed to lower-case in Hono. Hence, you will have to make them lower-cased in validation object.

import { object, string } from 'valibot'
import { sValidator } from '@hono/standard-validator'

const schema = object({
  'content-type': string(),
  'user-agent': string(),
})

app.post('/author', sValidator('header', schema), (c) => {
  const headers = c.req.valid('header')
  // do something with headers
})

Author

Rokas Muningis https://github.com/muningis

License

MIT

FAQs

Package last updated on 13 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts