Latest Version: 0.9.6.2

IPhoneNumberValidator

Validates, and converts phone numbers to +##-###-#######. Adapted from RFC 3966

>>> p = IPhoneNumberValidator()
>>> p.to_python('333-3333')
Traceback (most recent call last):
    ...
Invalid: Please enter a number, with area code, in the form +##-###-#######.
>>> p.to_python('0555/4860-300')
'+49-555-4860-300'
>>> p.to_python('0555-49924-51')
'+49-555-49924-51'
>>> p.to_python('0555/8114100')
'+49-555-8114100'
>>> p.to_python('0555 8114100')
'+49-555-8114100'
>>> p.to_python(' +49 (0)555 350 60 0')
'+49-555-35060-0'
>>> p.to_python('+49 555 350600')
'+49-555-350600'
>>> p.to_python('0049/ 555/ 871 82 96')
'+49-555-87182-96'
>>> p.to_python('0555-2 50-30')
'+49-555-250-30'
>>> p.to_python('(05 55)4 94 33 47')
'+49-555-49433-47'
>>> p.to_python('+973-555431')
'+973-555431'
>>> p.to_python('1-393-555-3939')
'+1-393-555-3939'
>>> p.to_python('+43 (1) 55528/0')
'+43-1-55528-0'
>>> p.to_python('+43 5555 429 62-0')
'+43-5555-42962-0'
>>> p.to_python('00 218 55 33 50 317 321')
'+218-55-3350317-321'
>>> p.to_python('+218 (0)55-3636639/38')
'+218-55-3636639-38'

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
noneType:
The input must be a string (not None)
phoneFormat:
Please enter a number, with area code, in the form +##-###-#######.

Attributes

a __singletonmethods__

('to_python', 'from_python')

a accept_python

True

a compound

False

a default_cc

None

a not_empty

False

a repeating

False

a strip

True

Methods

f __call__(self, *args, **kw) ...

f __classinit__(cls, new_attrs) ...

f __classsourcerepr__(cls, source, binding=None) ...

f __init__(self, *args, **kw) ...

f __initargs__(self, new_attrs) ...

f __sourcerepr__(self, source, binding=None) ...

See the source for more information.

Top