added validation for end Date, end date should be greater than start date

This commit is contained in:
Pramod Mahajan 2025-04-16 00:16:53 +05:30
parent 7ebd8dcc00
commit b73a7fc5ab

View File

@ -41,7 +41,14 @@ const ManageProjectInfo = ( {project,handleSubmitForm, onClose} ) =>
return num; 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( { const {register, control, handleSubmit, formState: {errors}, reset, getValues} = useForm( {