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 changesets
pull/565/head
chimame 2024-06-09 13:15:41 +09:00 committed by GitHub
parent ce635982d7
commit 7375c096b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 27 additions and 22 deletions

View File

@ -0,0 +1,5 @@
---
'@hono/valibot-validator': minor
---
changed supported version of valibot to 0.31.0 or later

View File

@ -28,12 +28,12 @@
"homepage": "https://github.com/honojs/middleware",
"peerDependencies": {
"hono": ">=3.9.0",
"valibot": ">=0.13.1 <1"
"valibot": ">=0.31.0 <1"
},
"devDependencies": {
"hono": "^4.0.10",
"jest": "^29.7.0",
"rimraf": "^5.0.5",
"valibot": "^0.24.1"
"valibot": "^0.31.0"
}
}

View File

@ -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 type { BaseSchema, BaseSchemaAsync, Input, Output, SafeParseResult } from 'valibot'
import type { GenericSchema, GenericSchemaAsync, InferInput, InferOutput, SafeParseResult } 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>,
c: Context<E, P>
) => 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
export const vValidator = <
T extends BaseSchema | BaseSchemaAsync,
T extends GenericSchema | GenericSchemaAsync,
Target extends keyof ValidationTargets,
E extends Env,
P extends string,
In = Input<T>,
Out = Output<T>,
In = InferInput<T>,
Out = InferOutput<T>,
I extends HonoInput = {
in: HasUndefined<In> extends true
? {
@ -56,6 +56,6 @@ export const vValidator = <
return c.json(result, 400)
}
const data = result.output as Output<T>
const data = result.output as InferOutput<T>
return data
})

View File

@ -1,6 +1,6 @@
import { Hono } from 'hono'
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'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@ -167,14 +167,14 @@ describe('Async', () => {
const app = new Hono()
const schemaAsync = objectAsync({
name: stringAsync(),
age: numberAsync(),
name: string(),
age: number(),
})
const querySchemaAsync = optionalAsync(
objectAsync({
search: optionalAsync(stringAsync()),
page: optionalAsync(numberAsync()),
search: optionalAsync(string()),
page: optionalAsync(number()),
})
)
@ -264,8 +264,8 @@ describe('With Hook Async', () => {
const app = new Hono()
const schemaAsync = objectAsync({
id: numberAsync(),
title: stringAsync(),
id: number(),
title: string(),
})
app.post(

View File

@ -2155,10 +2155,10 @@ __metadata:
hono: "npm:^4.0.10"
jest: "npm:^29.7.0"
rimraf: "npm:^5.0.5"
valibot: "npm:^0.24.1"
valibot: "npm:^0.31.0"
peerDependencies:
hono: ">=3.9.0"
valibot: ">=0.13.1 <1"
valibot: ">=0.31.0 <1"
languageName: unknown
linkType: soft
@ -18181,10 +18181,10 @@ __metadata:
languageName: node
linkType: hard
"valibot@npm:^0.24.1":
version: 0.24.1
resolution: "valibot@npm:0.24.1"
checksum: 637c3641bc800506982ea507c55b65154653ea1f38bf3c7ad6c0fc3dd3bead4644e2172ddd8cade2821c280886dd9d99b36e7a778607cae7dfab107de74c5547
"valibot@npm:^0.31.0":
version: 0.31.1
resolution: "valibot@npm:0.31.1"
checksum: 666abefeffe1b92e324bc1f35e9052929365d9646f324197d21a506ada07e605958853e04144996b698c866cc327be78138712a5b79e1dbe98caf52229b49fc0
languageName: node
linkType: hard