diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 2a1e4d7d2..baab481af 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -55,13 +55,6 @@ class CaseLogValidator < ActiveModel::Validator end end - def women_of_child_bearing_age_in_household(record) - (1..8).any? do |n| - next if record["person_#{n}_gender"].nil? || record["person_#{n}_age"].nil? - record["person_#{n}_gender"] == "Female" && record["person_#{n}_age"] >= 16 && record["person_#{n}_age"] <= 50 - end - end - def validate(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 @@ -78,6 +71,15 @@ class CaseLogValidator < ActiveModel::Validator validation_methods.each { |meth| public_send(meth, record) } end end + + private + + def women_of_child_bearing_age_in_household(record) + (1..8).any? do |n| + next if record["person_#{n}_gender"].nil? || record["person_#{n}_age"].nil? + record["person_#{n}_gender"] == "Female" && record["person_#{n}_age"] >= 16 && record["person_#{n}_age"] <= 50 + end + end end class CaseLog < ApplicationRecord