throw error if date is invalid