From 7338e2038b3fd6b73da5f2ebc6cac677b9a39fbe Mon Sep 17 00:00:00 2001 From: Bruce Bolt Date: Wed, 8 Nov 2023 11:16:42 +0000 Subject: [PATCH] Permit apostrophe in email address Some email addresses contain an apostrophe in the person's name before the `@` symbol, but we are currently disallowing them. This adds that character into the validation for email addresses. Resolved https://govuk.zendesk.com/agent/tickets/5548904. --- app/models/support/requests/requester.rb | 2 +- spec/models/support/requests/requester_spec.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/support/requests/requester.rb b/app/models/support/requests/requester.rb index 818efea6f..f4693aafd 100644 --- a/app/models/support/requests/requester.rb +++ b/app/models/support/requests/requester.rb @@ -7,7 +7,7 @@ class Requester attr_accessor :name attr_reader :email - VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i + VALID_EMAIL_REGEX = /\A[\w+\-.']+@[a-z\d\-.]+\.[a-z]+\z/i validates :email, presence: true diff --git a/spec/models/support/requests/requester_spec.rb b/spec/models/support/requests/requester_spec.rb index 125d59166..61c012866 100644 --- a/spec/models/support/requests/requester_spec.rb +++ b/spec/models/support/requests/requester_spec.rb @@ -12,10 +12,12 @@ module Requests it { should allow_value("ab @c.com").for(:email) } it { should allow_value("ab@c.com ").for(:email) } it { should allow_value(" ab@c.com").for(:email) } + it { should allow_value("a'b@c.com ").for(:email) } it { should_not allow_value("ab").for(:email) } it { should allow_value("").for(:collaborator_emails) } it { should allow_value("ab@c.com").for(:collaborator_emails) } + it { should allow_value("a'b@c.com").for(:collaborator_emails) } it { should allow_value("ab@c.com, de@f.com").for(:collaborator_emails) } it { should_not allow_value("ab, de@f.com").for(:collaborator_emails) } it { should_not allow_value("ab@c.com111").for(:collaborator_emails) }