Validate end dates are after start dates

Create issue
Issue #179 new
Mick Zijdel created an issue

Date validations are not built-in, but there is probably a gem for that.

Comments (2)

  1. Hayden Ball

    You probably don’t need a gem - a validation function for this is fairly simple:

    def ensure_start_date_before_end_date
      return unless start_date.present? && end_date.present?
      return if start_date < end_date
      errors.add(:base, :start_date_after_end_date)

  2. Mick Zijdel reporter

    That’s fair, but there would be multiple models who need that code and I am reluctant to share and maintain code if there already exists a date validation gem that can do all that for us 😉

  3. Log in to comment