I finished the project but when I submit my link for validation, appears the error message in my console: (error: Validation Error: date: Cast to date failed for value “Invalid Date” (type string) at path “date”) for many times.
You’re actually printing that error in your test.save() callback of your POST user route. If you add some route input logging and log the value of checkedDate, you’ll get
error:ValidationError: date: Cast to date failed for value "Invalid Date" (type string) at path "date"
So when the date is not specified, your handling is setting checkedDate to “Invalid Date” which is the defined behavior for the string parser in new Date(). I don’t know if you intended to use noDateHandler to set the date, but right now you have just defined the function and it’s not actually being called anywhere.