From 7bafad54f966a3306713e921c7440b869521d3e8 Mon Sep 17 00:00:00 2001 From: Chuma McPhoy Date: Tue, 22 Oct 2024 10:46:45 +0200 Subject: [PATCH] fix(SW-360): better country required msg --- components/Forms/Register/schema.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/Forms/Register/schema.ts b/components/Forms/Register/schema.ts index 982641d2c..2584a02fe 100644 --- a/components/Forms/Register/schema.ts +++ b/components/Forms/Register/schema.ts @@ -3,6 +3,7 @@ import { z } from "zod" import { passwordValidator } from "@/utils/passwordValidator" import { phoneValidator } from "@/utils/phoneValidator" +const countryRequiredMsg = "Country is required" export const registerSchema = z.object({ firstName: z .string() @@ -23,7 +24,12 @@ export const registerSchema = z.object({ ), dateOfBirth: z.string().min(1), address: z.object({ - countryCode: z.string(), + countryCode: z + .string({ + required_error: countryRequiredMsg, + invalid_type_error: countryRequiredMsg, + }) + .min(1, countryRequiredMsg), zipCode: z.string().min(1), }), password: passwordValidator("Password is required"),