Browse Source
* Add date validation for mrc date * validate the rest of the date fieldspull/99/head
kosiakkatrina
3 years ago
committed by
GitHub
6 changed files with 83 additions and 5 deletions
@ -0,0 +1,21 @@ |
|||||||
|
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 |
Loading…
Reference in new issue