From 87fe23003570e9514f3d1988150b36e0ecf23620 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 7 Sep 2020 16:12:47 +0500 Subject: [PATCH] Add default email validation type to application.yml --- config/application.yml.sample | 3 +++ config/initializers/truemail.rb | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/config/application.yml.sample b/config/application.yml.sample index d5753adb6..478af216f 100644 --- a/config/application.yml.sample +++ b/config/application.yml.sample @@ -156,6 +156,9 @@ lhv_dev_mode: 'false' epp_session_timeout_seconds: '300' +# Email validation setting for Truemail gem. Possible values: 'regex', 'mx', 'smtp' +default_email_validation_type: 'regex' + # Since the keys for staging are absent from the repo, we need to supply them separate for testing. test: payments_seb_bank_certificate: 'test/fixtures/files/seb_bank_cert.pem' diff --git a/config/initializers/truemail.rb b/config/initializers/truemail.rb index f4517fbc0..badc0cc82 100644 --- a/config/initializers/truemail.rb +++ b/config/initializers/truemail.rb @@ -28,7 +28,10 @@ Truemail.configure do |config| # Optional parameter. You can predefine default validation type for # Truemail.validate('email@email.com') call without with-parameter # Available validation types: :regex, :mx, :smtp - if Rails.env.production? + if ENV['default_email_validation_type'].present? && + %w[regex, mx, smtp].include?(ENV['default_email_validation_type']) + config.default_validation_type = ENV['default_email_validation_type'].to_sym + elsif Rails.env.production? config.default_validation_type = :mx else config.default_validation_type = :regex