From 8dd7cd4b9c017bc0377ee5cecdee1498cc60f977 Mon Sep 17 00:00:00 2001 From: olegphenomenon Date: Fri, 12 Nov 2021 11:32:01 +0200 Subject: [PATCH] added validation checker before create --- app/interactions/actions/contact_create.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/interactions/actions/contact_create.rb b/app/interactions/actions/contact_create.rb index 8c6cb2282..ad5612322 100644 --- a/app/interactions/actions/contact_create.rb +++ b/app/interactions/actions/contact_create.rb @@ -12,9 +12,26 @@ module Actions maybe_remove_address maybe_attach_legal_doc validate_ident + maybe_change_email commit end + def maybe_change_email + return if Rails.env.test? + + [:regex, :mx].each do |m| + r = Actions::SimpleMailValidator.run(email: contact.email, level: m) + + unless r.success + contact.add_epp_error('2005', nil, r.errors, I18n.t(:parameter_value_syntax_error)) + @error = true + return + end + end + + true + end + def maybe_remove_address return if Contact.address_processing?