|
|
@ -395,13 +395,17 @@ class Location < ApplicationRecord |
|
|
|
def deactivation_date_errors |
|
|
|
def deactivation_date_errors |
|
|
|
return unless implicit_run_deactivation_validations |
|
|
|
return unless implicit_run_deactivation_validations |
|
|
|
|
|
|
|
|
|
|
|
collection_start_date = FormHandler.instance.current_collection_start_date |
|
|
|
if deactivation_date.blank? |
|
|
|
if deactivation_date_type.blank? |
|
|
|
if deactivation_date_type.blank? |
|
|
|
errors.add(:deactivation_date_type, message: I18n.t("validations.location.deactivation_date.not_selected")) |
|
|
|
errors.add(:deactivation_date_type, message: I18n.t("validations.location.deactivation_date.not_selected")) |
|
|
|
elsif deactivation_date.blank? |
|
|
|
elsif deactivation_date_type == "other" |
|
|
|
errors.add(:deactivation_date, message: I18n.t("validations.location.deactivation_date.invalid")) |
|
|
|
errors.add(:deactivation_date, message: I18n.t("validations.location.deactivation_date.invalid")) |
|
|
|
elsif !deactivation_date.between?(collection_start_date, Date.new(2200, 1, 1)) |
|
|
|
end |
|
|
|
errors.add(:deactivation_date, message: I18n.t("validations.location.deactivation_date.out_of_range", date: collection_start_date.to_formatted_s(:govuk_date))) |
|
|
|
else |
|
|
|
|
|
|
|
collection_start_date = FormHandler.instance.current_collection_start_date |
|
|
|
|
|
|
|
if !deactivation_date.between?(collection_start_date, Date.new(2200, 1, 1)) |
|
|
|
|
|
|
|
errors.add(:deactivation_date, message: I18n.t("validations.location.deactivation_date.out_of_range", date: collection_start_date.to_formatted_s(:govuk_date))) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|