Module: InvestorProfileForm::Validator

Extended by:
ActiveSupport::Concern
Included in:
InvestorProfileForm
Defined in:
app/form_models/investor_profile_form.rb

Instance Method Summary collapse

Instance Method Details

#age_must_be_above_18Object



103
104
105
106
# File 'app/form_models/investor_profile_form.rb', line 103

def age_must_be_above_18
  too_young = date_of_birth.present? && TimeDifference.between(date_of_birth, Date.today).in_years.to_i < 18
  errors.add(:date_of_birth, I18n.t('investor_form.must_be_older_than_18')) if too_young
end

#id_document_blank?Boolean

Returns:

  • (Boolean)


116
117
118
# File 'app/form_models/investor_profile_form.rb', line 116

def id_document_blank?
  @member.id_document.blank?
end

#is_passport_blank_and_not_local_region?Boolean

Returns:

  • (Boolean)


120
121
122
123
# File 'app/form_models/investor_profile_form.rb', line 120

def is_passport_blank_and_not_local_region?
  is_local_region = %w(Singapore Indonesia).include? nationality
  !is_local_region && @member.id_document_additional.blank?
end

#name_and_account_holder_must_be_the_sameObject



108
109
110
111
112
113
114
# File 'app/form_models/investor_profile_form.rb', line 108

def 
  if name.to_s != .to_s
    msg = I18n.t('investor_form.name_and_account_holder_must_be_the_same')
    errors.add(:name, msg)
    errors.add(:account_holder, msg)
  end
end