Browse Source

Allow + in the numbers

pull/1714/head
Kat 3 years ago
parent
commit
544de55344
  1. 2
      app/controllers/users_controller.rb
  2. 9
      spec/requests/users_controller_spec.rb

2
app/controllers/users_controller.rb

@ -129,7 +129,7 @@ private
end end
def valid_phone_number?(number) def valid_phone_number?(number)
/^\d{11,}$/.match?(number) /^[+\d]{11,}$/.match?(number)
end end
def format_error_messages def format_error_messages

9
spec/requests/users_controller_spec.rb

@ -977,6 +977,15 @@ RSpec.describe UsersController, type: :request do
expect(page).not_to have_content(I18n.t("activerecord.errors.models.user.attributes.phone.invalid")) expect(page).not_to have_content(I18n.t("activerecord.errors.models.user.attributes.phone.invalid"))
end end
end end
context "when telephone number is in correct format and includes +" do
let(:phone) { "+12345678919" }
it "validates telephone number" do
request
expect(page).not_to have_content(I18n.t("activerecord.errors.models.user.attributes.phone.invalid"))
end
end
end end
end end

Loading…
Cancel
Save