record.errors.add"person_#{member_number}_age","Female tenant who is retired must be 60 or over"
end
ifage>70&&economic_status!="Retired"
record.errors.add"person_#{member_number}_economic_status","Tenant #{member_number} must be retired if over 70"
end
ifage<16
ifrelationship!="Child - includes young adult and grown-up"
record.errors.add"person_#{member_number}_relationship","Tenant #{member_number}'s relationship to tenant 1 must be Child if their age is under 16"
end
ifeconomic_status!="Child under 16"
record.errors.add"person_#{member_number}_economic_status","Tenant #{member_number} economic status must be Child under 16 if their age is under 16"
end
end
ifrelationship=="Partner"
ifpartner
record.errors.add"person_#{member_number}_relationship","Tenant can not have multiple partners"
elsifage<16||economic_status=="Child under 16"
record.errors.add"person_#{member_number}_relationship","Tenant can not be tenant 1's partner if they are under 16"
else
partner=true
end
end
ifrelationship=="Child - includes young adult and grown-up"
ifeconomic_status!="Unable to work because of long term sick or disability"||economic_status!="Other"||economic_status!="Prefer not to say"
record.errors.add"person_#{member_number}_economic_status","This is not a valid economic status for a child"
end
ifage>=16&&age<=19
ifeconomic_status!="Full-time student"||economic_status!="Prefer not to say"
record.errors.add"person_#{member_number}_economic_status","If relationship is child and age is between 16 and 19 - tenant #{member_number} must be a full time student or prefer not to say."
end
end
end
index=index+1
end
end
defvalidate(record)
# If we've come from the form UI we only want to validate the specific fields
# that have just been submitted. If we're submitting a log via API or Bulk Upload
record.errors.add"person_#{person_num}_economic_status","Tenant #{person_num} must be retired if over 70"
end
ifage<16&&economic_status!="Child under 16"
record.errors.add"person_#{person_num}_economic_status","Tenant #{person_num} economic status must be Child under 16 if their age is under 16"
end
ifage>=16&&age<=19&&(economic_status!="Full-time student"||economic_status!="Prefer not to say")
record.errors.add"person_#{person_num}_economic_status","If age is between 16 and 19 - tenant #{person_num} must be a full time student or prefer not to say."