Browse Source

Move lettings startdate 14 day validation to enforce order

pull/2279/head
Rachael Booth 2 years ago
parent
commit
dcc355fced
  1. 4
      app/models/validations/date_validations.rb
  2. 4
      app/models/validations/setup_validations.rb

4
app/models/validations/date_validations.rb

@ -34,10 +34,6 @@ module Validations::DateValidations
def validate_startdate(record)
return unless record.startdate && date_valid?("startdate", record)
if !FeatureToggle.allow_future_form_use? && record.startdate > Time.zone.today + 14.days
record.errors.add :startdate, I18n.t("validations.setup.startdate.later_than_14_days_after")
end
if record["voiddate"].present? && record.startdate < record["voiddate"]
record.errors.add :startdate, I18n.t("validations.setup.startdate.after_void_date")
end

4
app/models/validations/setup_validations.rb

@ -14,6 +14,10 @@ module Validations::SetupValidations
unless record.startdate.between?(first_collection_start_date, current_collection_end_date)
record.errors.add :startdate, startdate_validation_error_message
end
if record.startdate > Time.zone.today + 14.days
record.errors.add :startdate, I18n.t("validations.setup.startdate.later_than_14_days_after")
end
end
def validate_organisation(record)

Loading…
Cancel
Save