Browse Source

validate the rest of the date fields

pull/97/head
Kat 4 years ago
parent
commit
78397d5189
  1. 18
      app/validations/date_validations.rb

18
app/validations/date_validations.rb

@ -1,7 +1,21 @@
module DateValidations
def validate_property_major_repairs(record)
if record.mrcdate.is_a?(ActiveSupport::TimeWithZone) && record.mrcdate.year.zero?
record.errors.add :mrcdate, "Please enter a valid date"
date_valid?("mrcdate", record)
end
def validate_tenancy_start_date(record)
date_valid?("startdate", record)
end
def validate_sale_completion_date(record)
date_valid?("sale_completion_date", record)
end
private
def date_valid?(question, record)
if record[question].is_a?(ActiveSupport::TimeWithZone) && record[question].year.zero?
record.errors.add question, "Please enter a valid date"
end
end
end

Loading…
Cancel
Save