|
|
|
@ -15,14 +15,6 @@ class CaseLogValidator < ActiveModel::Validator
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def validate_api_reasonable_preference(record) |
|
|
|
|
if record.reasonable_preference == "No" |
|
|
|
|
if record.reasonable_preference_reason_homeless || record.reasonable_preference_reason_unsatisfactory_housing || record.reasonable_preference_reason_medical_grounds || record.reasonable_preference_reason_avoid_hardship || record.reasonable_preference_reason_do_not_know |
|
|
|
|
record.errors.add :reasonable_preference_reason, "- no resasons can be set to true, if reasonable preference is No" |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def validate_reasonable_preference(record) |
|
|
|
|
if record.homelessness == "No" && record.reasonable_preference == "Yes" |
|
|
|
|
record.errors.add :reasonable_preference, "can not be Yes if Not Homesless imediately prior to this letting has been selected" |
|
|
|
@ -30,6 +22,10 @@ class CaseLogValidator < ActiveModel::Validator
|
|
|
|
|
if !record.reasonable_preference_reason_homeless && !record.reasonable_preference_reason_unsatisfactory_housing && !record.reasonable_preference_reason_medical_grounds && !record.reasonable_preference_reason_avoid_hardship && !record.reasonable_preference_reason_do_not_know |
|
|
|
|
record.errors.add :reasonable_preference_reason, "- if reasonable preference is Yes, a reason must be given" |
|
|
|
|
end |
|
|
|
|
elsif record.reasonable_preference == "No" |
|
|
|
|
if record.reasonable_preference_reason_homeless || record.reasonable_preference_reason_unsatisfactory_housing || record.reasonable_preference_reason_medical_grounds || record.reasonable_preference_reason_avoid_hardship || record.reasonable_preference_reason_do_not_know |
|
|
|
|
record.errors.add :reasonable_preference_reason, "- if reasonable preference is no, no reasons should be given" |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|