diff --git a/app/models/actions/contact_create.rb b/app/models/actions/contact_create.rb index ff46ed817..a771dbde4 100644 --- a/app/models/actions/contact_create.rb +++ b/app/models/actions/contact_create.rb @@ -26,16 +26,7 @@ module Actions end def validate_ident - if ident.present? - if ident[:ident_type].blank? - contact.add_epp_error('2003', nil, 'ident_type', - I18n.t('errors.messages.required_ident_attribute_missing')) - @error = true - elsif !%w[priv org birthday].include?(ident[:ident_type]) - contact.add_epp_error('2003', nil, 'ident_type', 'Invalid ident type') - @error = true - end - end + validate_ident_integrity if ident.present? && ident[:ident_type] != 'birthday' && ident[:ident_country_code].blank? contact.add_epp_error('2003', nil, 'ident_country_code', @@ -50,6 +41,19 @@ module Actions contact.identifier = identifier end + def validate_ident_integrity + return if ident.blank? + + if ident[:ident_type].blank? + contact.add_epp_error('2003', nil, 'ident_type', + I18n.t('errors.messages.required_ident_attribute_missing')) + @error = true + elsif !%w[priv org birthday].include?(ident[:ident_type]) + contact.add_epp_error('2003', nil, 'ident_type', 'Invalid ident type') + @error = true + end + end + def maybe_attach_legal_doc return unless legal_document