skip to Main Content

when creating a user from aws via the console. they used below regex validation pattern as per below screenshot.

regex pattern

"^+[1-9][0-9]{0,24}$"

but when i try this mobile number with python it was matched. but in the console or api it gives an error called invalid mobile number

sample mobile number +80570497

cognito user creation

python script

>>> re.match(r"^+[1-9][0-9]{0,24}$", "+80570497")
<re.Match object; span=(0, 9), match='+80570497'>
>>> 

2

Answers


  1. Cognito said:

    Enter the user’s phone number, including country code. The phone number is not a required attribute based on your selections and user pool configuration.

    You are missing the country code in your phone number you have to follow the E.164 format. For example, if this is a Sri Lanka phone number, it should be written as +9480570497, where 94 is the country calling code for Sri Lanka.

    Login or Signup to reply.
  2. Cognito seems to be doing some more validation besides the regex from the screenshot. For example numbers starting with +80,+21,+259 and more.
    Looks like it does not allow any country codes that’s are currently unassigned from this list https://en.wikipedia.org/wiki/List_of_country_calling_codes

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search