Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

How to configure phone number validation to take white spaces into account ?

RaduPop
New Contributor
New Contributor

Hello, 

We are trying to create a regex expression for phone number validation which will match duplicate phone numbers regardless of the format. ex. : if a user has phone number +012345678 and new request is made for a user with phone number +01 234 5678 the regex should warn that this phone number is already in use by another user.

This is the original regex that we are currently using : ${PhoneNumber.matches('\\+[1-9]{1}[0-9\\s]*')}

Any help is much appreciated. 

4 REPLIES 4

jayasudha
Saviynt Employee
Saviynt Employee

Hi,

The regex is used for validating the format of the phone number. If you want to validate the phone number with or without spaces you can use this  \+[1-9]{2}\s?[0-9]{3}\s?[0-9]{4}

Could you please elaborate your use case here.

Thanks and regards,

Jayasudha R

RaduPop
New Contributor
New Contributor

Hello,

I need to create a user that has the phone number ex. +33288991 and another person wants to create a user with the same number but with spaces between the number ex. +33 288 991 so in this case I want the application to say that the phone number is duplicated , that this phone number is already assigned to another user even if the phone number is with spaces between. 

Thanks!

Hi,

1. You have to use the regex given to accept the phone number with or without spaces.  \+[1-9]{2}\s?[0-9]{3}\s?[0-9]{4}

2.You need to remove spaces from the phone number if any.

3.You have to run a query  to get the phone numbers from the database and match with the phone number from UI to avoid duplicates. This cannot be done via regex.

Regards,

Jayasudha R

rushikeshvartak
All-Star
All-Star

You can handle above in Workflow using SQL query if above logic  found auto reject request 


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.