chore: Update valibot to version 0.31.0 (#553)
* chore: Update valibot to version 0.31.0 * Modify update valibot to version 0.31.0 * Modify update yarn.lock to valibot 0.31.0 * Add CHANGELOG using changesetspull/565/head
parent
ce635982d7
commit
7375c096b5
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@hono/valibot-validator': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
changed supported version of valibot to 0.31.0 or later
|
|
@ -28,12 +28,12 @@
|
||||||
"homepage": "https://github.com/honojs/middleware",
|
"homepage": "https://github.com/honojs/middleware",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"hono": ">=3.9.0",
|
"hono": ">=3.9.0",
|
||||||
"valibot": ">=0.13.1 <1"
|
"valibot": ">=0.31.0 <1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"hono": "^4.0.10",
|
"hono": "^4.0.10",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"rimraf": "^5.0.5",
|
"rimraf": "^5.0.5",
|
||||||
"valibot": "^0.24.1"
|
"valibot": "^0.31.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import type { Context, MiddlewareHandler, Env, ValidationTargets, Input as HonoInput } from 'hono'
|
import type { Context, Env, Input as HonoInput, MiddlewareHandler, ValidationTargets } from 'hono'
|
||||||
import { validator } from 'hono/validator'
|
import { validator } from 'hono/validator'
|
||||||
import type { BaseSchema, BaseSchemaAsync, Input, Output, SafeParseResult } from 'valibot'
|
import type { GenericSchema, GenericSchemaAsync, InferInput, InferOutput, SafeParseResult } from 'valibot'
|
||||||
import { safeParseAsync } from 'valibot'
|
import { safeParseAsync } from 'valibot'
|
||||||
|
|
||||||
type Hook<T extends BaseSchema | BaseSchemaAsync, E extends Env, P extends string> = (
|
type Hook<T extends GenericSchema | GenericSchemaAsync, E extends Env, P extends string> = (
|
||||||
result: SafeParseResult<T>,
|
result: SafeParseResult<T>,
|
||||||
c: Context<E, P>
|
c: Context<E, P>
|
||||||
) => Response | Promise<Response> | void | Promise<Response | void>
|
) => Response | Promise<Response> | void | Promise<Response | void>
|
||||||
|
@ -11,12 +11,12 @@ type Hook<T extends BaseSchema | BaseSchemaAsync, E extends Env, P extends strin
|
||||||
type HasUndefined<T> = undefined extends T ? true : false
|
type HasUndefined<T> = undefined extends T ? true : false
|
||||||
|
|
||||||
export const vValidator = <
|
export const vValidator = <
|
||||||
T extends BaseSchema | BaseSchemaAsync,
|
T extends GenericSchema | GenericSchemaAsync,
|
||||||
Target extends keyof ValidationTargets,
|
Target extends keyof ValidationTargets,
|
||||||
E extends Env,
|
E extends Env,
|
||||||
P extends string,
|
P extends string,
|
||||||
In = Input<T>,
|
In = InferInput<T>,
|
||||||
Out = Output<T>,
|
Out = InferOutput<T>,
|
||||||
I extends HonoInput = {
|
I extends HonoInput = {
|
||||||
in: HasUndefined<In> extends true
|
in: HasUndefined<In> extends true
|
||||||
? {
|
? {
|
||||||
|
@ -56,6 +56,6 @@ export const vValidator = <
|
||||||
return c.json(result, 400)
|
return c.json(result, 400)
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = result.output as Output<T>
|
const data = result.output as InferOutput<T>
|
||||||
return data
|
return data
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Hono } from 'hono'
|
import { Hono } from 'hono'
|
||||||
import type { Equal, Expect } from 'hono/utils/types'
|
import type { Equal, Expect } from 'hono/utils/types'
|
||||||
import { number, object, string, optional, numberAsync, objectAsync, stringAsync, optionalAsync } from 'valibot'
|
import { number, object, objectAsync, optional, optionalAsync, string } from 'valibot'
|
||||||
import { vValidator } from '../src'
|
import { vValidator } from '../src'
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
@ -167,14 +167,14 @@ describe('Async', () => {
|
||||||
const app = new Hono()
|
const app = new Hono()
|
||||||
|
|
||||||
const schemaAsync = objectAsync({
|
const schemaAsync = objectAsync({
|
||||||
name: stringAsync(),
|
name: string(),
|
||||||
age: numberAsync(),
|
age: number(),
|
||||||
})
|
})
|
||||||
|
|
||||||
const querySchemaAsync = optionalAsync(
|
const querySchemaAsync = optionalAsync(
|
||||||
objectAsync({
|
objectAsync({
|
||||||
search: optionalAsync(stringAsync()),
|
search: optionalAsync(string()),
|
||||||
page: optionalAsync(numberAsync()),
|
page: optionalAsync(number()),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -264,8 +264,8 @@ describe('With Hook Async', () => {
|
||||||
const app = new Hono()
|
const app = new Hono()
|
||||||
|
|
||||||
const schemaAsync = objectAsync({
|
const schemaAsync = objectAsync({
|
||||||
id: numberAsync(),
|
id: number(),
|
||||||
title: stringAsync(),
|
title: string(),
|
||||||
})
|
})
|
||||||
|
|
||||||
app.post(
|
app.post(
|
||||||
|
|
12
yarn.lock
12
yarn.lock
|
@ -2155,10 +2155,10 @@ __metadata:
|
||||||
hono: "npm:^4.0.10"
|
hono: "npm:^4.0.10"
|
||||||
jest: "npm:^29.7.0"
|
jest: "npm:^29.7.0"
|
||||||
rimraf: "npm:^5.0.5"
|
rimraf: "npm:^5.0.5"
|
||||||
valibot: "npm:^0.24.1"
|
valibot: "npm:^0.31.0"
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
hono: ">=3.9.0"
|
hono: ">=3.9.0"
|
||||||
valibot: ">=0.13.1 <1"
|
valibot: ">=0.31.0 <1"
|
||||||
languageName: unknown
|
languageName: unknown
|
||||||
linkType: soft
|
linkType: soft
|
||||||
|
|
||||||
|
@ -18181,10 +18181,10 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"valibot@npm:^0.24.1":
|
"valibot@npm:^0.31.0":
|
||||||
version: 0.24.1
|
version: 0.31.1
|
||||||
resolution: "valibot@npm:0.24.1"
|
resolution: "valibot@npm:0.31.1"
|
||||||
checksum: 637c3641bc800506982ea507c55b65154653ea1f38bf3c7ad6c0fc3dd3bead4644e2172ddd8cade2821c280886dd9d99b36e7a778607cae7dfab107de74c5547
|
checksum: 666abefeffe1b92e324bc1f35e9052929365d9646f324197d21a506ada07e605958853e04144996b698c866cc327be78138712a5b79e1dbe98caf52229b49fc0
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue