indiaval 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
indiaval/__init__.py ADDED
@@ -0,0 +1,11 @@
1
+ from .validators import (
2
+ is_valid_mobile,
3
+ is_valid_pincode,
4
+ is_valid_pan,
5
+ is_valid_ifsc,
6
+ is_valid_aadhaar,
7
+ is_valid_gstin,
8
+ is_valid_vehicle_number,
9
+ )
10
+
11
+ __version__ = "0.2.0"
indiaval/validators.py ADDED
@@ -0,0 +1,73 @@
1
+ import re
2
+
3
+ _MOBILE = re.compile(r"(?:\+91[\-\s]?|91|0)?[6-9]\d{9}")
4
+ _PINCODE = re.compile(r"[1-9]\d{5}")
5
+ _PAN = re.compile(r"[A-Z]{5}\d{4}[A-Z]")
6
+ _IFSC = re.compile(r"[A-Z]{4}0[A-Z0-9]{6}")
7
+ _AADHAAR = re.compile(r"[2-9]\d{11}")
8
+ _GSTIN = re.compile(r"(0[1-9]|[1-2]\d|3[0-8])[A-Z]{5}\d{4}[A-Z][1-9A-Z]Z[0-9A-Z]")
9
+ _GSTIN_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
10
+ _VEHICLE = re.compile(r"[A-Z]{2}\d{2}[A-Z]{1,3}\d{4}")
11
+
12
+ _D = (
13
+ (0, 1, 2, 3, 4, 5, 6, 7, 8, 9), (1, 2, 3, 4, 0, 6, 7, 8, 9, 5),
14
+ (2, 3, 4, 0, 1, 7, 8, 9, 5, 6), (3, 4, 0, 1, 2, 8, 9, 5, 6, 7),
15
+ (4, 0, 1, 2, 3, 9, 5, 6, 7, 8), (5, 9, 8, 7, 6, 0, 4, 3, 2, 1),
16
+ (6, 5, 9, 8, 7, 1, 0, 4, 3, 2), (7, 6, 5, 9, 8, 2, 1, 0, 4, 3),
17
+ (8, 7, 6, 5, 9, 3, 2, 1, 0, 4), (9, 8, 7, 6, 5, 4, 3, 2, 1, 0),
18
+ )
19
+ _P = (
20
+ (0, 1, 2, 3, 4, 5, 6, 7, 8, 9), (1, 5, 7, 6, 2, 8, 3, 0, 9, 4),
21
+ (5, 8, 0, 3, 7, 9, 6, 1, 4, 2), (8, 9, 1, 6, 0, 4, 3, 5, 2, 7),
22
+ (9, 4, 5, 3, 1, 2, 6, 8, 7, 0), (4, 2, 8, 6, 5, 7, 3, 9, 0, 1),
23
+ (2, 7, 9, 3, 8, 0, 6, 4, 1, 5), (7, 0, 4, 6, 9, 1, 3, 2, 5, 8),
24
+ )
25
+
26
+
27
+ def is_valid_mobile(value: str) -> bool:
28
+ """Indian mobile number, with optional +91, 91 or 0 prefix."""
29
+ return bool(_MOBILE.fullmatch(value.strip()))
30
+
31
+
32
+ def is_valid_pincode(value: str) -> bool:
33
+ """6-digit PIN code that doesn't start with 0."""
34
+ return bool(_PINCODE.fullmatch(value.strip()))
35
+
36
+
37
+ def is_valid_pan(value: str) -> bool:
38
+ """PAN format: 5 letters, 4 digits, 1 letter (e.g. ABCDE1234F)."""
39
+ return bool(_PAN.fullmatch(value.strip().upper()))
40
+
41
+
42
+ def is_valid_ifsc(value: str) -> bool:
43
+ """IFSC format: 4 letters, a zero, 6 letters or digits (e.g. SBIN0001234)."""
44
+ return bool(_IFSC.fullmatch(value.strip().upper()))
45
+
46
+
47
+ def is_valid_aadhaar(value: str) -> bool:
48
+ """12-digit Aadhaar number (spaces allowed) with a valid Verhoeff checksum."""
49
+ number = value.replace(" ", "")
50
+ if not _AADHAAR.fullmatch(number):
51
+ return False
52
+ c = 0
53
+ for i, ch in enumerate(reversed(number)):
54
+ c = _D[c][_P[i % 8][int(ch)]]
55
+ return c == 0
56
+
57
+
58
+ def is_valid_gstin(value: str) -> bool:
59
+ """15-character GSTIN with a valid checksum character."""
60
+ gstin = value.strip().upper()
61
+ if not _GSTIN.fullmatch(gstin):
62
+ return False
63
+ total = 0
64
+ for i, ch in enumerate(gstin[:14]):
65
+ v = _GSTIN_CHARS.index(ch) * (1 if i % 2 == 0 else 2)
66
+ total += v // 36 + v % 36
67
+ return _GSTIN_CHARS[(36 - total % 36) % 36] == gstin[14]
68
+
69
+
70
+ def is_valid_vehicle_number(value: str) -> bool:
71
+ """Vehicle registration like KA01AB1234 (spaces and hyphens allowed)."""
72
+ number = value.upper().replace(" ", "").replace("-", "")
73
+ return bool(_VEHICLE.fullmatch(number))
@@ -0,0 +1,79 @@
1
+ Metadata-Version: 2.4
2
+ Name: indiaval
3
+ Version: 0.2.0
4
+ Summary: Validators for Indian mobile, PIN code, PAN, IFSC, Aadhaar, GSTIN and vehicle numbers
5
+ Author: Greeshma Gowda K A
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/greeshmagowdaa4-lgtm/indiaval
8
+ Keywords: india,validation,aadhaar,pan,gstin,ifsc
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Dynamic: license-file
15
+
16
+ # indiaval
17
+
18
+ ![Tests](https://github.com/greeshmagowdaa4-lgtm/indiaval/actions/workflows/tests.yml/badge.svg)
19
+
20
+ Simple Python validators for common Indian data formats: mobile numbers, PIN codes, PAN, IFSC codes, Aadhaar numbers, GSTIN and vehicle registration numbers.
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ pip install indiaval
26
+ ```
27
+
28
+ To work on the code locally:
29
+
30
+ ```bash
31
+ git clone https://github.com/greeshmagowdaa4-lgtm/indiaval.git
32
+ cd indiaval
33
+ pip install -e .
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ ```python
39
+ from indiaval import (
40
+ is_valid_mobile,
41
+ is_valid_pincode,
42
+ is_valid_pan,
43
+ is_valid_ifsc,
44
+ is_valid_aadhaar,
45
+ is_valid_gstin,
46
+ is_valid_vehicle_number,
47
+ )
48
+
49
+ is_valid_mobile("+91 9876543210") # True
50
+ is_valid_pincode("560001") # True
51
+ is_valid_pan("ABCDE1234F") # True
52
+ is_valid_ifsc("SBIN0001234") # True
53
+ is_valid_aadhaar("234567890124") # True
54
+ is_valid_gstin("27AAPFU0939F1ZV") # True
55
+ is_valid_vehicle_number("KA01AB1234") # True
56
+
57
+ is_valid_pincode("060001") # False (can't start with 0)
58
+ ```
59
+
60
+ ## Validators
61
+
62
+ | Function | Checks |
63
+ |----------|--------|
64
+ | `is_valid_mobile` | 10-digit number starting with 6-9, optional `+91`, `91` or `0` prefix |
65
+ | `is_valid_pincode` | 6 digits, first digit not 0 |
66
+ | `is_valid_pan` | 5 letters, 4 digits, 1 letter |
67
+ | `is_valid_ifsc` | 4 letters, a zero, then 6 letters or digits |
68
+ | `is_valid_aadhaar` | 12 digits, first digit 2-9, valid Verhoeff checksum |
69
+ | `is_valid_gstin` | 15-character GSTIN with a valid state code and checksum |
70
+ | `is_valid_vehicle_number` | State code, 2 digits, 1-3 letters, 4 digits (e.g. `KA01AB1234`) |
71
+
72
+ These check the **format** only. They don't confirm that a number or code actually exists.
73
+
74
+ ## Running tests
75
+
76
+ ```bash
77
+ pip install pytest
78
+ python -m pytest
79
+ ```
@@ -0,0 +1,7 @@
1
+ indiaval/__init__.py,sha256=-CRHq7f7rbmGtF-8vkDvtvV6KG7wY0JONG-OVBYHXeg,211
2
+ indiaval/validators.py,sha256=jNDiTZ94lzPeGbzFNKuLdxqWpSVtHIKRklcbIF2DnUs,2750
3
+ indiaval-0.2.0.dist-info/licenses/LICENSE,sha256=_ahQV5fq0hJj23VATBM7OCma6bX9D1ua14ec5hL1Nok,1098
4
+ indiaval-0.2.0.dist-info/METADATA,sha256=x1BYKrNk5Ae1b5pQG4nravAHkZl_Sw5BuaX-6aNZv3g,2408
5
+ indiaval-0.2.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
6
+ indiaval-0.2.0.dist-info/top_level.txt,sha256=YuMKu6Sz_8fn6zTcNC0a1v3V_nS6HDvBG7lE_1KW8PM,9
7
+ indiaval-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 greeshmagowdaa4-lgtm
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ indiaval