@hono/standard-validator
Advanced tools
+25
| # @hono/standard-validator | ||
| ## 0.1.3 | ||
| ### Patch Changes | ||
| - [#1291](https://github.com/honojs/middleware/pull/1291) [`a22fbe78e5d3e8aa3790b39bbb590649cc34df2d`](https://github.com/honojs/middleware/commit/a22fbe78e5d3e8aa3790b39bbb590649cc34df2d) Thanks [@BarryThePenguin](https://github.com/BarryThePenguin)! - Import `jsr:@standard-schema/spec` | ||
| ## 0.1.2 | ||
| ### Patch Changes | ||
| - [#964](https://github.com/honojs/middleware/pull/964) [`352507bc06857466b75dbf47f6f514d28719f47c`](https://github.com/honojs/middleware/commit/352507bc06857466b75dbf47f6f514d28719f47c) Thanks [@paihu](https://github.com/paihu)! - fix result type | ||
| ## 0.1.1 | ||
| ### Patch Changes | ||
| - [#962](https://github.com/honojs/middleware/pull/962) [`8e5f49394bf6405396c2a166f26a17ef0cc644e2`](https://github.com/honojs/middleware/commit/8e5f49394bf6405396c2a166f26a17ef0cc644e2) Thanks [@muningis](https://github.com/muningis)! - Remove dead code | ||
| ## 0.1.0 | ||
| ### Minor Changes | ||
| - [#887](https://github.com/honojs/middleware/pull/887) [`f77d7ba2e2226f86c302deb1a598cd7c9c8f35da`](https://github.com/honojs/middleware/commit/f77d7ba2e2226f86c302deb1a598cd7c9c8f35da) Thanks [@muningis](https://github.com/muningis)! - Initial implementation for Standard Schema support |
+3
-3
@@ -21,7 +21,7 @@ "use strict"; | ||
| // src/index.ts | ||
| var src_exports = {}; | ||
| __export(src_exports, { | ||
| var index_exports = {}; | ||
| __export(index_exports, { | ||
| sValidator: () => sValidator | ||
| }); | ||
| module.exports = __toCommonJS(src_exports); | ||
| module.exports = __toCommonJS(index_exports); | ||
| var import_validator = require("hono/validator"); | ||
@@ -28,0 +28,0 @@ var sValidator = (target, schema, hook) => ( |
+1
-1
@@ -11,3 +11,3 @@ import { StandardSchemaV1 } from '@standard-schema/spec'; | ||
| success: false; | ||
| error: ReadonlyArray<StandardSchemaV1.Issue>; | ||
| error: readonly StandardSchemaV1.Issue[]; | ||
| data: T; | ||
@@ -14,0 +14,0 @@ }) & { |
+1
-1
@@ -11,3 +11,3 @@ import { StandardSchemaV1 } from '@standard-schema/spec'; | ||
| success: false; | ||
| error: ReadonlyArray<StandardSchemaV1.Issue>; | ||
| error: readonly StandardSchemaV1.Issue[]; | ||
| data: T; | ||
@@ -14,0 +14,0 @@ }) & { |
+24
-16
| { | ||
| "name": "@hono/standard-validator", | ||
| "version": "0.1.2", | ||
| "version": "0.1.3", | ||
| "description": "Validator middleware using Standard Schema", | ||
@@ -11,5 +11,10 @@ "type": "module", | ||
| ".": { | ||
| "types": "./dist/index.d.ts", | ||
| "import": "./dist/index.js", | ||
| "require": "./dist/index.cjs" | ||
| "import": { | ||
| "types": "./dist/index.d.ts", | ||
| "default": "./dist/index.js" | ||
| }, | ||
| "require": { | ||
| "types": "./dist/index.d.cts", | ||
| "default": "./dist/index.cjs" | ||
| } | ||
| } | ||
@@ -21,7 +26,8 @@ }, | ||
| "scripts": { | ||
| "test": "tsc --noEmit && vitest --run", | ||
| "build": "tsup ./src/index.ts --format esm,cjs --dts", | ||
| "publint": "publint", | ||
| "prerelease": "yarn build && yarn test", | ||
| "release": "yarn publish" | ||
| "build": "tsup ./src/index.ts", | ||
| "prepack": "yarn build", | ||
| "publint": "attw --pack && publint", | ||
| "typecheck": "tsc -b tsconfig.json", | ||
| "test": "vitest", | ||
| "version:jsr": "yarn version:set $npm_package_version" | ||
| }, | ||
@@ -35,3 +41,4 @@ "license": "MIT", | ||
| "type": "git", | ||
| "url": "https://github.com/honojs/middleware.git" | ||
| "url": "git+https://github.com/honojs/middleware.git", | ||
| "directory": "packages/standard-validator" | ||
| }, | ||
@@ -44,12 +51,13 @@ "homepage": "https://github.com/honojs/middleware", | ||
| "devDependencies": { | ||
| "@arethetypeswrong/cli": "^0.17.4", | ||
| "@standard-schema/spec": "1.0.0", | ||
| "arktype": "^2.0.0-rc.26", | ||
| "hono": "^4.0.10", | ||
| "publint": "^0.2.7", | ||
| "tsup": "^8.1.0", | ||
| "typescript": "^5.7.3", | ||
| "hono": "^4.8.4", | ||
| "publint": "^0.3.9", | ||
| "tsup": "^8.4.0", | ||
| "typescript": "^5.8.2", | ||
| "valibot": "^1.0.0-beta.9", | ||
| "vitest": "^1.4.0", | ||
| "vitest": "^3.2.4", | ||
| "zod": "^3.24.0" | ||
| } | ||
| } | ||
| } |
+9
-5
| # Standard Schema validator middleware for Hono | ||
| [](https://codecov.io/github/honojs/middleware) | ||
| The validator middleware using [Standard Schema Spec](https://github.com/standard-schema/standard-schema) for [Hono](https://honojs.dev) applications. | ||
@@ -8,4 +10,4 @@ You can write a schema with any validation library supporting Standard Schema and validate the incoming values. | ||
| ### Basic: | ||
| ### Basic: | ||
| ```ts | ||
@@ -18,3 +20,3 @@ import { z } from 'zod' | ||
| age: z.number(), | ||
| }); | ||
| }) | ||
@@ -31,2 +33,3 @@ app.post('/author', sValidator('json', schema), (c) => { | ||
| ### Hook: | ||
| ```ts | ||
@@ -45,3 +48,5 @@ app.post( | ||
| ### Headers: | ||
| Headers are internally transformed to lower-case in Hono. Hence, you will have to make them lower-cased in validation object. | ||
| ```ts | ||
@@ -53,4 +58,4 @@ import { object, string } from 'valibot' | ||
| 'content-type': string(), | ||
| 'user-agent': string() | ||
| }); | ||
| 'user-agent': string(), | ||
| }) | ||
@@ -63,3 +68,2 @@ app.post('/author', sValidator('header', schema), (c) => { | ||
| ## Author | ||
@@ -66,0 +70,0 @@ |
9564
19.85%7
16.67%70
6.06%10
11.11%