From 02ef6dc9346158c1983b23aa4e4613b3d2e6d486 Mon Sep 17 00:00:00 2001 From: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com> Date: Mon, 20 Jan 2025 13:03:54 +0400 Subject: [PATCH] Fix raycast bug (#18756) --- apps/api/v1/lib/validations/shared/jsonSchema.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/api/v1/lib/validations/shared/jsonSchema.ts b/apps/api/v1/lib/validations/shared/jsonSchema.ts index bfc7ae1f2b..423b28e955 100644 --- a/apps/api/v1/lib/validations/shared/jsonSchema.ts +++ b/apps/api/v1/lib/validations/shared/jsonSchema.ts @@ -1,9 +1,11 @@ import { z } from "zod"; // Helper schema for JSON fields -type Literal = boolean | number | string; +type Literal = boolean | number | string | null; type Json = Literal | { [key: string]: Json } | Json[]; -const literalSchema = z.union([z.string(), z.number(), z.boolean()]); +const literalSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]); +const jsonObjectSchema = z.record(z.lazy(() => jsonSchema)); +const jsonArraySchema = z.array(z.lazy(() => jsonSchema)); export const jsonSchema: z.ZodSchema = z.lazy(() => - z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)]) + z.union([literalSchema, jsonObjectSchema, jsonArraySchema]) );