Store phone number as the user entered it

It’s confusing to the user to have their phone number played back to them in
a format that they didn’t enter it. We’ve seen multiple times that people enter
0781… and then don’t recognise their own phone number when it’s played back as
+44781…

The API can handle phone numbers in any format as of
https://github.com/alphagov/notifications-api/pull/134

So there is no need to reformat the user’s phone number before storing it now.
This commit is contained in:
Chris Hill-Scott
2016-03-08 07:17:39 +00:00
parent eb3734f1d1
commit 93b4419bb2
3 changed files with 1 additions and 153 deletions

View File

@@ -37,19 +37,10 @@ class UKMobileNumber(TelField):
def pre_validate(self, form):
try:
self.data = validate_phone_number(self.data)
validate_phone_number(self.data)
except InvalidPhoneError as e:
raise ValidationError(e.message)
def post_validate(self, form, validation_stopped):
if len(self.data) != 9:
return
# TODO implement in the render field method.
# API's require no spaces in the number
# self.data = '+44 7{} {} {}'.format(*re.findall('...', self.data))
self.data = format_phone_number(self.data)
def mobile_number():
return UKMobileNumber('Mobile phone number',