diff --git a/roadside-forms-frontend/frontend_web_app/src/components/Event/validationSchema.js b/roadside-forms-frontend/frontend_web_app/src/components/Event/validationSchema.js index 87a9c38f7..ac3ec5f06 100644 --- a/roadside-forms-frontend/frontend_web_app/src/components/Event/validationSchema.js +++ b/roadside-forms-frontend/frontend_web_app/src/components/Event/validationSchema.js @@ -356,6 +356,16 @@ export const validationSchema = Yup.object().shape( new Date(), "Date of impound is required" ) + ) + .test( + "date_of_impound", + "Date of Impound cannot be before date of driving", + function (value) { + if (value && this.parent.date_of_driving) { + return moment(value) >= moment(this.parent.date_of_driving); + } + return true; + } ), }), // Only for VI, required if VI is selected