8000 Expanded validation for BE VAT numbers · nuno-andre/python-stdnum@3a592e4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3a592e4

Browse files
JonasGearthurdejong
authored andcommitted
Expanded validation for BE VAT numbers
Specifically invalidated all-zero numbers Closes arthurdejong#240
1 parent c5eb2d8 commit 3a592e4

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

stdnum/be/vat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def validate(number):
6161
"""Check if the number is a valid VAT number. This checks the length,
6262
formatting and check digit."""
6363
number = compact(number)
64-
if not isdigits(number):
64+
if not isdigits(number) or int(number) <= 0:
6565
raise InvalidFormat()
6666
if len(number) != 10:
6767
raise InvalidLength()

tests/test_be_vat.doctest

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
test_be_vat.doctest - more detailed doctests for stdnum.be.vat module
2+
3+
Copyright (C) 2020 Arthur de Jong
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18+
02110-1301 USA
19+
20+
21+
This file contains more detailed doctests for the stdnum.be.vat module. It
22+
tries to test more corner cases and detailed functionality that is not
23+
really useful as module documentation.
24+
25+
>>> from stdnum.be import vat
26+
27+
28+
Tests for corner cases.
29+
30+
>>> vat.validate('BE0000000000')
31+
Traceback (most recent call last):
32+
...
33+
InvalidFormat: ...
34+
>>> vat.validate('000000')
35+
Traceback (most recent call last):
36+
...
37+
InvalidFormat: ...

0 commit comments

Comments
 (0)
0