I'd like to move all of my phone number validation into one django validator field. How can I use this phone number validator to include stripping all non numeric fields in the string?
e.g. '123.123.1234' would become '1231231234'
I know you can do it with a replace such as replaceAll( "[^\\d]", "" )
but it needs to be one regex for the django validator
validate_phone_number = RegexValidator(
regex=re.compile(r'^\+?1?\d{9,15}$'),
message="Phone number must be entered in the format: '+999999999'. Up to 15 digits allowed.",
code='invalid'
)