Add new model presence validates

- Only validate :date_of_birth and :postal_code presence when the
  application has configured Remote Census and their alias fields
  has values.
This commit is contained in:
taitus
2019-05-14 12:37:33 +02:00
committed by Javi Martín
parent c0c967b961
commit 6e62ea81a9
2 changed files with 67 additions and 29 deletions

View File

@@ -5,6 +5,8 @@ class Verification::Management::Document
attr_accessor :document_type, :document_number, :date_of_birth, :postal_code
validates :document_type, :document_number, presence: true
validates :date_of_birth, presence: true, if: -> { Setting.force_presence_date_of_birth? }
validates :postal_code, presence: true, if: -> { Setting.force_presence_postal_code? }
delegate :username, :email, to: :user, allow_nil: true