From 553112c2c6440f3326e9fde839681620acb3090e Mon Sep 17 00:00:00 2001 From: Aditya Mathur <57684218+MathurAditya724@users.noreply.github.com> Date: Wed, 13 Nov 2024 02:01:42 +0530 Subject: [PATCH] fix: exported Hook type in valibot and typebox validators (#821) * fix: exported Hook type * chore: add changeset packages --- .changeset/ninety-shoes-lay.md | 6 ++++++ packages/typebox-validator/src/index.ts | 2 +- packages/valibot-validator/src/index.ts | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/ninety-shoes-lay.md diff --git a/.changeset/ninety-shoes-lay.md b/.changeset/ninety-shoes-lay.md new file mode 100644 index 000000000..cae056cb1 --- /dev/null +++ b/.changeset/ninety-shoes-lay.md @@ -0,0 +1,6 @@ +--- +'@hono/typebox-validator': patch +'@hono/valibot-validator': patch +--- + +exported the Hook type diff --git a/packages/typebox-validator/src/index.ts b/packages/typebox-validator/src/index.ts index 2f52ee834..3b38f5d8d 100644 --- a/packages/typebox-validator/src/index.ts +++ b/packages/typebox-validator/src/index.ts @@ -3,7 +3,7 @@ import { Value, type ValueError } from '@sinclair/typebox/value' import type { Context, Env, MiddlewareHandler, ValidationTargets } from 'hono' import { validator } from 'hono/validator' -type Hook = ( +export type Hook = ( result: { success: true; data: T } | { success: false; errors: ValueError[] }, c: Context ) => Response | Promise | void diff --git a/packages/valibot-validator/src/index.ts b/packages/valibot-validator/src/index.ts index 36834916c..e430583f6 100644 --- a/packages/valibot-validator/src/index.ts +++ b/packages/valibot-validator/src/index.ts @@ -3,7 +3,7 @@ import { validator } from 'hono/validator' import type { GenericSchema, GenericSchemaAsync, InferInput, InferOutput, SafeParseResult } from 'valibot' import { safeParseAsync } from 'valibot' -type Hook = ( +export type Hook = ( result: SafeParseResult, c: Context ) => Response | Promise | void | Promise