diff --git a/attributs.py b/attributs.py index 467b5ca..f1f6940 100644 --- a/attributs.py +++ b/attributs.py @@ -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 diff --git a/crans_utils.py b/crans_utils.py index ed02c11..cf9a693 100644 --- a/crans_utils.py +++ b/crans_utils.py @@ -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)