0
0
mirror of https://github.com/honojs/hono.git synced 2024-11-21 18:18:57 +01:00

fix(types): allow string[] | File[] for RPC form value (#3117)

This commit is contained in:
Yusuke Wada 2024-07-10 10:23:07 +09:00 committed by GitHub
parent 4c401fd661
commit ec58511247
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 4 deletions

View File

@ -1927,9 +1927,11 @@ type MergeTypedResponse<T> = T extends Promise<infer T2>
////// /////
////////////////////////////////////////
export type FormValue = string | File
export type ValidationTargets = {
json: any
form: Record<string, string | File>
form: Record<string, FormValue | FormValue[]>
query: Record<string, string | string[]>
param: Record<string, string> | Record<string, string | undefined>
header: Record<string, string>

View File

@ -3,7 +3,13 @@ import type { ZodSchema } from 'zod'
import { z } from 'zod'
import { Hono } from '../hono'
import { HTTPException } from '../http-exception'
import type { ErrorHandler, ExtractSchema, MiddlewareHandler, ValidationTargets } from '../types'
import type {
ErrorHandler,
ExtractSchema,
FormValue,
MiddlewareHandler,
ValidationTargets,
} from '../types'
import type { StatusCode } from '../utils/http-status'
import type { Equal, Expect } from '../utils/types'
import type { ValidationFunction } from './validator'
@ -743,7 +749,7 @@ it('With path parameters', () => {
$put: {
input: {
form: {
title: string | File
title: FormValue | FormValue[]
}
} & {
param: {
@ -789,7 +795,7 @@ it('`on`', () => {
$purge: {
input: {
form: {
tag: string | File
tag: FormValue | FormValue[]
}
} & {
query: {