Skip to content

Commit ec58511

Browse files
authored
fix(types): allow string[] | File[] for RPC form value (#3117)
1 parent 4c401fd commit ec58511

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1927,9 +1927,11 @@ type MergeTypedResponse<T> = T extends Promise<infer T2>
19271927
////// /////
19281928
////////////////////////////////////////
19291929

1930+
export type FormValue = string | File
1931+
19301932
export type ValidationTargets = {
19311933
json: any
1932-
form: Record<string, string | File>
1934+
form: Record<string, FormValue | FormValue[]>
19331935
query: Record<string, string | string[]>
19341936
param: Record<string, string> | Record<string, string | undefined>
19351937
header: Record<string, string>

src/validator/validator.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import type { ZodSchema } from 'zod'
33
import { z } from 'zod'
44
import { Hono } from '../hono'
55
import { HTTPException } from '../http-exception'
6-
import type { ErrorHandler, ExtractSchema, MiddlewareHandler, ValidationTargets } from '../types'
6+
import type {
7+
ErrorHandler,
8+
ExtractSchema,
9+
FormValue,
10+
MiddlewareHandler,
11+
ValidationTargets,
12+
} from '../types'
713
import type { StatusCode } from '../utils/http-status'
814
import type { Equal, Expect } from '../utils/types'
915
import type { ValidationFunction } from './validator'
@@ -743,7 +749,7 @@ it('With path parameters', () => {
743749
$put: {
744750
input: {
745751
form: {
746-
title: string | File
752+
title: FormValue | FormValue[]
747753
}
748754
} & {
749755
param: {
@@ -789,7 +795,7 @@ it('`on`', () => {
789795
$purge: {
790796
input: {
791797
form: {
792-
tag: string | File
798+
tag: FormValue | FormValue[]
793799
}
794800
} & {
795801
query: {

0 commit comments

Comments
 (0)