check for invalid date and raise an exception