From 72240082e71f06fd6569536dc8777073ec8efe3b Mon Sep 17 00:00:00 2001 From: PritamIT2023 Date: Tue, 25 Jun 2024 19:06:56 +0530 Subject: [PATCH] fix(global): :bug: profilebasic info edit logo validation profilebasic info edit logo validation Ref: #56 --- app/formValidationMap.registry.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/formValidationMap.registry.js b/app/formValidationMap.registry.js index 492d7d4..24081c6 100644 --- a/app/formValidationMap.registry.js +++ b/app/formValidationMap.registry.js @@ -30,11 +30,17 @@ export const ValidationsRegistry = { string() .trim() .matches(/^[a-zA-Z\s]+$/, "Only alphabets are allowed for this field "), - photo: mixed() - .test("fileSize", "File size must be less than 5MB", (value) => { - if (!value) return true; - return value.size <= 5242880; - }), + photo: mixed().when("myfile", { + isType : (value) => typeof value === "string", + // Allow null for strings + otherwise: (schema) => + schema + .test("fileSize", "File size must be less than 5MB", (value) => { + if (!value) return true; // Allow empty files + return value.size <= 5 * 1024 * 1024; // Check for 5MB limit + }), + then: (schema) => schema.nullable(true), + }), }, profileEducation: { board: