You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
511 B
22 lines
511 B
3 years ago
|
module DateValidations
|
||
|
def validate_property_major_repairs(record)
|
||
|
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
|