From ec58511247d7b9c33fff92ea992c127c6363eec0 Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Wed, 10 Jul 2024 10:23:07 +0900 Subject: [PATCH] fix(types): allow `string[] | File[]` for RPC form value (#3117) --- src/types.ts | 4 +++- src/validator/validator.test.ts | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/types.ts b/src/types.ts index a81858de..3a539911 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1927,9 +1927,11 @@ type MergeTypedResponse = T extends Promise ////// ///// //////////////////////////////////////// +export type FormValue = string | File + export type ValidationTargets = { json: any - form: Record + form: Record query: Record param: Record | Record header: Record diff --git a/src/validator/validator.test.ts b/src/validator/validator.test.ts index 12028b93..2044a489 100644 --- a/src/validator/validator.test.ts +++ b/src/validator/validator.test.ts @@ -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: {