I have this validation code, I want to add another part to it where it checks to make sure that the date selected in not more than fives years in the past from today. Thoughts!
let dateFormatter = DateFormatter()
dateFormatter.dateStyle = .medium
let date1 = dateFormatter.date (from: termStartDate.text!)
guard let startDate = date1 , startDate < Date() else {
let alert = UIAlertController(title: "Input Error", message: "Select Date less than today", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)
return
}