Cognito's expectations for a phone number is to be fully numerical except for the initial + sign.
Although the Authenticator's Phone Number Field only shows the numeric keyboard for manual input, it's still possible to end up with non-numeric characters by using the Auto-Fill option, or simply by pasting a phone number from the clipboard.
The problem is that phone numbers are typically formatted in a way that include hyphens, spaces and parentheses (e.g. +1 (123) 456-7890 instead of just +11234567890). So attempting to submit a phone number using any of these characters results in an error, as Cognito rejects the request.
While the easiest fix would be to remove any non-numeric character from being displayed in the Phone Number Field, I've decided to allow them on the customer facing field, but remove them from the internal field that is used when submitting to Cognito. The reasoning for this is that striping formatting would create a subpar experience for customers using Auto-Fill or pasting phone numbers.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Issue #, if available:
Description of changes:
Cognito's expectations for a phone number is to be fully numerical except for the initial
+
sign. Although the Authenticator's Phone Number Field only shows the numeric keyboard for manual input, it's still possible to end up with non-numeric characters by using the Auto-Fill option, or simply by pasting a phone number from the clipboard.The problem is that phone numbers are typically formatted in a way that include hyphens, spaces and parentheses (e.g.
+1 (123) 456-7890
instead of just+11234567890
). So attempting to submit a phone number using any of these characters results in an error, as Cognito rejects the request.While the easiest fix would be to remove any non-numeric character from being displayed in the Phone Number Field, I've decided to allow them on the customer facing field, but remove them from the internal field that is used when submitting to Cognito. The reasoning for this is that striping formatting would create a subpar experience for customers using Auto-Fill or pasting phone numbers.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.