From ff11b928290f31fb40f6dc14ef60c91880ed1c8a Mon Sep 17 00:00:00 2001 From: kingbri <8082010+bdashore3@users.noreply.github.com> Date: Fri, 27 Dec 2024 23:26:04 -0500 Subject: [PATCH] Valibot: Pass JSON schema config with resolver The default behavior of toJsonSchema is to error. However, when parsing actions such as transform, the input schema is still parsed if the error level is set to "warn". Therefore, make it possible for users to pass these options via the resolver. Signed-off-by: kingbri <8082010+bdashore3@users.noreply.github.com> --- packages/core/src/valibot.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/core/src/valibot.ts b/packages/core/src/valibot.ts index e20ebc8..380a7d4 100644 --- a/packages/core/src/valibot.ts +++ b/packages/core/src/valibot.ts @@ -16,6 +16,7 @@ import { type InferOutput, parseAsync, } from "valibot"; +import type { ConversionConfig } from "@valibot/to-json-schema"; import type { HasUndefined, OpenAPIRouteHandlerConfig, @@ -25,10 +26,10 @@ import { generateValidatorDocs, uniqueSymbol } from "./utils"; export function resolver< T extends BaseSchema> ->(schema: T): ResolverResult { +>(schema: T, config?: ConversionConfig): ResolverResult { return { builder: async (options?: OpenAPIRouteHandlerConfig) => ({ - schema: await convert(toJsonSchema(schema)), + schema: await convert(toJsonSchema(schema, config)), }), validator: async (value) => { await parseAsync(schema, value);