[attributs] Nettoyage de la validation du Téléphone
This commit is contained in:
parent
2d0faa1d54
commit
9b79664264
2 changed files with 4 additions and 2 deletions
|
@ -160,6 +160,8 @@ class tel(Attr):
|
|||
|
||||
def parse_value(self, val):
|
||||
self.value = format_tel(val)
|
||||
if len(self.value) == 0:
|
||||
raise ValueError("Numéro de téléphone invalide ('%s')" % val)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.value
|
||||
|
|
|
@ -80,8 +80,8 @@ def format_tel(tel):
|
|||
Retourne le numéro formaté.
|
||||
"""
|
||||
tel_f = tel.strip()
|
||||
if tel.startswith(u"+"):
|
||||
tel_f = u"00" + tel[1:]
|
||||
if tel_f.startswith(u"+"):
|
||||
tel_f = u"00" + tel_f[1:]
|
||||
if u"(0)" in tel_f:
|
||||
tel_f = tel_f.replace(u"(0)", u"")
|
||||
tel_f = re.sub(r'\D', '', tel_f)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue