From b73a7fc5ab07486669c9086211878170aa4bd531 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Wed, 16 Apr 2025 00:16:53 +0530 Subject: [PATCH] added validation for end Date, end date should be greater than start date --- src/components/Project/ManageProjectInfo.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/Project/ManageProjectInfo.jsx b/src/components/Project/ManageProjectInfo.jsx index 8e68b5f3..08808fa8 100644 --- a/src/components/Project/ManageProjectInfo.jsx +++ b/src/components/Project/ManageProjectInfo.jsx @@ -41,7 +41,14 @@ const ManageProjectInfo = ( {project,handleSubmitForm, onClose} ) => return num; }), - } ) + } ) .refine((data) => { + const start = new Date(data.startDate); + const end = new Date(data.endDate); + return end > start; + }, { + path: ['endDate'], // attaches the error to the endDate field + message: 'End Date must be greater than Start Date', + }); const {register, control, handleSubmit, formState: {errors}, reset, getValues} = useForm( {