2 changed files with 17 additions and 3 deletions
@ -1,7 +1,21 @@ |
|||||||
module DateValidations |
module DateValidations |
||||||
def validate_property_major_repairs(record) |
def validate_property_major_repairs(record) |
||||||
if record.mrcdate.is_a?(ActiveSupport::TimeWithZone) && record.mrcdate.year.zero? |
date_valid?("mrcdate", record) |
||||||
record.errors.add :mrcdate, "Please enter a valid date" |
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 |
end |
||||||
end |
end |
||||||
|
Loading…
Reference in new issue