Skip to content

Commit

Permalink
fix(types): allow string[] | File[] for RPC form value (#3117)
Browse files Browse the repository at this point in the history
  • Loading branch information
yusukebe authored Jul 10, 2024
1 parent 4c401fd commit ec58511
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
12 changes: 9 additions & 3 deletions src/validator/validator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -743,7 +749,7 @@ it('With path parameters', () => {
$put: {
input: {
form: {
title: string | File
title: FormValue | FormValue[]
}
} & {
param: {
Expand Down Expand Up @@ -789,7 +795,7 @@ it('`on`', () => {
$purge: {
input: {
form: {
tag: string | File
tag: FormValue | FormValue[]
}
} & {
query: {
Expand Down

0 comments on commit ec58511

Please sign in to comment.