Merge pull request #2357 from internetee/2338-fix-syntax-error-in-epp-2005

Fixed message format for epp 2005 error
This commit is contained in:
Timo Võhmar 2022-04-18 16:39:25 +03:00 committed by GitHub
commit f21f347bcd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 8 deletions

View file

@ -19,12 +19,12 @@ module Actions
def maybe_change_email def maybe_change_email
return if Rails.env.test? return if Rails.env.test?
[:regex, :mx].each do |m| %i[regex mx].each do |m|
result = Actions::SimpleMailValidator.run(email: contact.email, level: m) result = Actions::SimpleMailValidator.run(email: contact.email, level: m)
next if result next if result
contact.add_epp_error('2005', nil, "email didn't pass validation", I18n.t(:parameter_value_syntax_error)) err_text = "email '#{contact.email}' didn't pass validation"
contact.add_epp_error('2005', nil, nil, "#{I18n.t(:parameter_value_syntax_error)} #{err_text}")
@error = true @error = true
return return
end end

View file

@ -23,11 +23,12 @@ module Actions
def maybe_change_email def maybe_change_email
return if Rails.env.test? return if Rails.env.test?
[:regex, :mx].each do |m| %i[regex mx].each do |m|
result = Actions::SimpleMailValidator.run(email: @new_attributes[:email], level: m) result = Actions::SimpleMailValidator.run(email: @new_attributes[:email], level: m)
next if result next if result
contact.add_epp_error('2005', nil, "email didn't pass validation", I18n.t(:parameter_value_syntax_error)) err_text = "email '#{new_attributes[:email]}' didn't pass validation"
contact.add_epp_error('2005', nil, nil, "#{I18n.t(:parameter_value_syntax_error)} #{err_text}")
@error = true @error = true
return return
end end

View file

@ -136,11 +136,12 @@ module Actions
def validate_email(email) def validate_email(email)
return true if Rails.env.test? return true if Rails.env.test?
[:regex, :mx].each do |m| %i[regex mx].each do |m|
result = Actions::SimpleMailValidator.run(email: email, level: m) result = Actions::SimpleMailValidator.run(email: email, level: m)
next if result next if result
domain.add_epp_error('2005', nil, "#{email} didn't pass validation", I18n.t(:parameter_value_syntax_error)) err_text = "email #{email} didn't pass validation"
domain.add_epp_error('2005', nil, nil, "#{I18n.t(:parameter_value_syntax_error)} #{err_text}")
@error = true @error = true
return return
end end