File tree 1 file changed +11
-5
lines changed 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change 1
1
# nif.py - functions for handling French tax identification numbers
2
2
# coding: utf-8
3
3
#
4
- # Copyright (C) 2016 Dimitri Papadopoulos
4
+ # Copyright (C) 2016-2021 Dimitri Papadopoulos
5
5
#
6
6
# This library is free software; you can redistribute it and/or
7
7
# modify it under the terms of the GNU Lesser General Public
20
20
21
21
"""NIF (Numéro d'Immatriculation Fiscale, French tax identification number).
22
22
23
- The NIF (Numéro d'Immatriculation Fiscale, Numéro d'Identité Fiscale or
24
- Numéro d'Identification Fiscale) also known as numéro fiscal de référence or
25
- SPI (Simplification des Procédures d'Identification) is a 13-digit number
26
- issued by the French tax authorities to people for tax reporting purposes.
23
+ The NIF (Numéro d'Immatriculation Fiscale or Numéro d'Identification Fiscale)
24
+ also known as numéro fiscal de référence or SPI (Simplification des
25
+ Procédures d'Identification) is a 13-digit number issued by the French tax
26
+ authorities to people for tax reporting purposes.
27
27
28
28
More information:
29
29
36
36
Traceback (most recent call last):
37
37
...
38
38
InvalidLength: ...
39
+ >>> validate('9701987765432')
40
+ Traceback (most recent call last):
41
+ ...
42
+ InvalidComponent: ...
39
43
>>> format('0701987765432')
40
44
'07 01 987 765 432'
41
45
"""
@@ -55,6 +59,8 @@ def validate(number):
55
59
number = compact (number )
56
60
if not isdigits (number ):
57
61
raise InvalidFormat ()
62
+ if number [0 ] not in ('0' , '1' , '2' , '3' ):
63
+ raise InvalidComponent ()
58
64
if len (number ) != 13 :
59
65
raise InvalidLength ()
60
66
return number
You can’t perform that action at this time.
0 commit comments