Skip to content

Commit

Permalink
Fixed message format for epp 2005 error
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergei Tsõganov authored and Sergei Tsõganov committed Apr 14, 2022
1 parent 47a93b2 commit ecb23b4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion app/interactions/actions/contact_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def maybe_change_email

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
return
end
Expand Down
6 changes: 4 additions & 2 deletions app/interactions/actions/contact_update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ def call
def maybe_change_email
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)
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
return
end
Expand Down
6 changes: 4 additions & 2 deletions app/interactions/actions/domain_update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,13 @@ def start_validate_email(props)
def validate_email(email)
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)
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
return
end
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ en:
sim_error: 'SIM application error'
internal_error: 'Internal error'
client_side_status_editing_error: 'Parameter value policy error. Client-side object status management not supported'
parameter_value_syntax_error: 'Parameter value syntax error: '
parameter_value_syntax_error: 'Parameter value syntax error:'

# DEPP
activemodel:
Expand Down

0 comments on commit ecb23b4

Please sign in to comment.