|
|
|
@ -384,7 +384,7 @@ class Location < ApplicationRecord
|
|
|
|
|
|
|
|
|
|
def deactivation_date_errors(params) |
|
|
|
|
if params[:location][:deactivation_date].blank? && params[:location][:deactivation_date_type].blank? |
|
|
|
|
@location.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")) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
if params[:location][:deactivation_date_type] == "other" |
|
|
|
@ -395,11 +395,11 @@ class Location < ApplicationRecord
|
|
|
|
|
collection_start_date = FormHandler.instance.current_collection_start_date |
|
|
|
|
|
|
|
|
|
if [day, month, year].any?(&:blank?) |
|
|
|
|
@location.errors.add(:deactivation_date, message: I18n.t("validations.location.deactivation_date.not_entered")) |
|
|
|
|
errors.add(:deactivation_date, message: I18n.t("validations.location.deactivation_date.not_entered")) |
|
|
|
|
elsif !Date.valid_date?(year.to_i, month.to_i, day.to_i) |
|
|
|
|
@location.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 !Date.new(year.to_i, month.to_i, day.to_i).between?(collection_start_date, Date.new(2200, 1, 1)) |
|
|
|
|
@location.errors.add(:deactivation_date, message: I18n.t("validations.location.deactivation_date.out_of_range", date: collection_start_date.to_formatted_s(:govuk_date))) |
|
|
|
|
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 |
|
|
|
|