added validation for end Date, end date should be greater than start date
This commit is contained in:
parent
7ebd8dcc00
commit
b73a7fc5ab
@ -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( {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user