From ccbf282c69ef4f4373de6a54513d60c94f3e7f30 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 29 Nov 2024 13:07:24 +0100 Subject: [PATCH] Flag zod --- packages/server/src/middleware/zod-validator.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/server/src/middleware/zod-validator.ts b/packages/server/src/middleware/zod-validator.ts index 0ad346afc3..e8cc2c470a 100644 --- a/packages/server/src/middleware/zod-validator.ts +++ b/packages/server/src/middleware/zod-validator.ts @@ -1,11 +1,16 @@ -import { Ctx } from "@budibase/types" +import { features } from "@budibase/backend-core" +import { Ctx, FeatureFlag } from "@budibase/types" import { AnyZodObject } from "zod" import { fromZodError } from "zod-validation-error" function validate(schema: AnyZodObject, property: "body" | "params") { // Return a Koa middleware function - return (ctx: Ctx, next: any) => { + return async (ctx: Ctx, next: any) => { + if (!(await features.flags.isEnabled(FeatureFlag.USE_ZOD_VALIDATOR))) { + return next() + } + if (!schema) { return next() }