Skip to main content
This release was yanked — the latest version of @ryoppippi/hono-unknownutil-validator is 0.1.5. Jump to latest

Built and signed on GitHub Actions

unknownutil validator middleware for Hono

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
7 months ago (0.1.1)

Unknownutil validator middleware for Hono

JSR

The type validator middleware using unknownutil for Hono applications. You can write a schema with unknownutil and check the type of the incoming values.

Usage

import { is } from 'unknownutil'
import { uValidator } from '@hono/unknownutil-validator'

const schema = is.ObjectOf({
  name: is.String,
  age: is.Number,
})

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

Hook:

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

Author

Ryotaro "Justin" Kimura https://github.com/ryoppippi

License

MIT

Built and signed on
GitHub Actions
View transparency log

Add Package

deno add jsr:@ryoppippi/hono-unknownutil-validator

Import symbol

import * as hono_unknownutil_validator from "@ryoppippi/hono-unknownutil-validator";

---- OR ----

Import directly with a jsr specifier

import * as hono_unknownutil_validator from "jsr:@ryoppippi/hono-unknownutil-validator";

Add Package

npx jsr add @ryoppippi/hono-unknownutil-validator

Import symbol

import * as hono_unknownutil_validator from "@ryoppippi/hono-unknownutil-validator";

Add Package

yarn dlx jsr add @ryoppippi/hono-unknownutil-validator

Import symbol

import * as hono_unknownutil_validator from "@ryoppippi/hono-unknownutil-validator";

Add Package

pnpm dlx jsr add @ryoppippi/hono-unknownutil-validator

Import symbol

import * as hono_unknownutil_validator from "@ryoppippi/hono-unknownutil-validator";

Add Package

bunx jsr add @ryoppippi/hono-unknownutil-validator

Import symbol

import * as hono_unknownutil_validator from "@ryoppippi/hono-unknownutil-validator";