Module: Decidim::Votings::Census::FrontendFields

Extended by:
ActiveSupport::Concern
Included in:
CheckForm, InPersonForm, LoginForm
Defined in:
decidim-elections/app/forms/decidim/votings/census/frontend_fields.rb

Overview

Definition of the fields required for frontend forms

Instance Method Summary collapse

Instance Method Details

#birthdateObject



34
35
36
37
38
# File 'decidim-elections/app/forms/decidim/votings/census/frontend_fields.rb', line 34

def birthdate
  return unless [year, month, day].all? { |part| part.is_a? Numeric }

  format("%04d%02d%02d", year, month, day)
end

#check_birthdateObject



26
27
28
29
30
31
32
# File 'decidim-elections/app/forms/decidim/votings/census/frontend_fields.rb', line 26

def check_birthdate
  return unless birthdate

  errors.add(:birthdate, :invalid) if Date.civil(year, month, day) > Time.zone.today
rescue Date::Error
  errors.add(:birthdate, :invalid)
end