helakit 0.1.0__tar.gz

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.
Files changed (36) hide show
  1. helakit-0.1.0/.gitignore +45 -0
  2. helakit-0.1.0/CHANGELOG.md +16 -0
  3. helakit-0.1.0/LICENSE +201 -0
  4. helakit-0.1.0/PKG-INFO +198 -0
  5. helakit-0.1.0/README.md +159 -0
  6. helakit-0.1.0/pyproject.toml +108 -0
  7. helakit-0.1.0/src/helakit/__init__.py +23 -0
  8. helakit-0.1.0/src/helakit/_core/__init__.py +13 -0
  9. helakit-0.1.0/src/helakit/_core/base.py +28 -0
  10. helakit-0.1.0/src/helakit/_core/exceptions.py +21 -0
  11. helakit-0.1.0/src/helakit/_core/result.py +53 -0
  12. helakit-0.1.0/src/helakit/_data/__init__.py +5 -0
  13. helakit-0.1.0/src/helakit/_data/districts.py +15 -0
  14. helakit-0.1.0/src/helakit/_data/provinces.py +15 -0
  15. helakit-0.1.0/src/helakit/nic/__init__.py +10 -0
  16. helakit-0.1.0/src/helakit/nic/_data.py +18 -0
  17. helakit-0.1.0/src/helakit/nic/exceptions.py +9 -0
  18. helakit-0.1.0/src/helakit/nic/validator.py +38 -0
  19. helakit-0.1.0/src/helakit/phone/__init__.py +10 -0
  20. helakit-0.1.0/src/helakit/phone/exceptions.py +9 -0
  21. helakit-0.1.0/src/helakit/phone/validator.py +31 -0
  22. helakit-0.1.0/src/helakit/postal/__init__.py +10 -0
  23. helakit-0.1.0/src/helakit/postal/exceptions.py +9 -0
  24. helakit-0.1.0/src/helakit/postal/validator.py +30 -0
  25. helakit-0.1.0/src/helakit/py.typed +0 -0
  26. helakit-0.1.0/tests/__init__.py +0 -0
  27. helakit-0.1.0/tests/conftest.py +5 -0
  28. helakit-0.1.0/tests/test_core/__init__.py +0 -0
  29. helakit-0.1.0/tests/test_core/test_data.py +29 -0
  30. helakit-0.1.0/tests/test_core/test_result.py +60 -0
  31. helakit-0.1.0/tests/test_nic/__init__.py +0 -0
  32. helakit-0.1.0/tests/test_nic/test_validator.py +17 -0
  33. helakit-0.1.0/tests/test_phone/__init__.py +0 -0
  34. helakit-0.1.0/tests/test_phone/test_validator.py +17 -0
  35. helakit-0.1.0/tests/test_postal/__init__.py +0 -0
  36. helakit-0.1.0/tests/test_postal/test_validator.py +17 -0
@@ -0,0 +1,45 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.pyo
5
+ *$py.class
6
+ *.pyc
7
+
8
+ # Virtual environments
9
+ .venv/
10
+ venv/
11
+ env/
12
+
13
+ # Distribution / packaging
14
+ build/
15
+ dist/
16
+ *.egg-info/
17
+ *.egg
18
+ wheels/
19
+
20
+ # Test / coverage
21
+ .coverage
22
+ .coverage.*
23
+ coverage.xml
24
+ htmlcov/
25
+ .pytest_cache/
26
+ .hypothesis/
27
+
28
+ # Type checkers / linters
29
+ .mypy_cache/
30
+ .ruff_cache/
31
+ .pyre/
32
+ .pytype/
33
+
34
+ # mkdocs
35
+ site/
36
+
37
+ # Editors / IDEs
38
+ .idea/
39
+ .vscode/
40
+ *.swp
41
+ *.swo
42
+
43
+ # OS
44
+ .DS_Store
45
+ Thumbs.db
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0] - 2026-04-29
11
+
12
+ ### Added
13
+
14
+ - Initial scaffolding: package layout, validator stubs (NIC, phone, postal),
15
+ `ValidationResult` core, docs site, CI / docs / release workflows, and
16
+ development tooling (ruff, mypy, pytest, pre-commit).
helakit-0.1.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 <Your Name>
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
helakit-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,198 @@
1
+ Metadata-Version: 2.4
2
+ Name: helakit
3
+ Version: 0.1.0
4
+ Summary: A toolkit for validating and working with Sri Lankan data.
5
+ Project-URL: Homepage, https://github.com/Aswikinz/Helakit
6
+ Project-URL: Documentation, https://Aswikinz.github.io/Helakit/
7
+ Project-URL: Repository, https://github.com/Aswikinz/Helakit
8
+ Project-URL: Issues, https://github.com/Aswikinz/Helakit/issues
9
+ Project-URL: Changelog, https://github.com/Aswikinz/Helakit/blob/main/CHANGELOG.md
10
+ Author: The helakit authors
11
+ License-Expression: Apache-2.0
12
+ License-File: LICENSE
13
+ Keywords: nic,phone,postal,sri-lanka,validation
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Software Development :: Libraries
23
+ Requires-Python: >=3.10
24
+ Provides-Extra: dev
25
+ Requires-Dist: hypothesis>=6; extra == 'dev'
26
+ Requires-Dist: mypy>=1.10; extra == 'dev'
27
+ Requires-Dist: pre-commit>=3.7; extra == 'dev'
28
+ Requires-Dist: pytest-cov>=5; extra == 'dev'
29
+ Requires-Dist: pytest>=8; extra == 'dev'
30
+ Requires-Dist: ruff>=0.5; extra == 'dev'
31
+ Provides-Extra: docs
32
+ Requires-Dist: mike>=2.1; extra == 'docs'
33
+ Requires-Dist: mkdocs-gen-files>=0.5; extra == 'docs'
34
+ Requires-Dist: mkdocs-literate-nav>=0.6; extra == 'docs'
35
+ Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
36
+ Requires-Dist: mkdocs>=1.6; extra == 'docs'
37
+ Requires-Dist: mkdocstrings[python]>=0.25; extra == 'docs'
38
+ Description-Content-Type: text/markdown
39
+
40
+ # Helakit
41
+
42
+ *A toolkit for validating and working with Sri Lankan data.*
43
+
44
+ [![PyPI version](https://img.shields.io/pypi/v/helakit.svg)](https://pypi.org/project/helakit/)
45
+ [![Python versions](https://img.shields.io/pypi/pyversions/helakit.svg)](https://pypi.org/project/helakit/)
46
+ [![CI](https://github.com/Aswikinz/Helakit/actions/workflows/ci.yml/badge.svg)](https://github.com/Aswikinz/Helakit/actions/workflows/ci.yml)
47
+ [![Coverage](https://img.shields.io/codecov/c/github/Aswikinz/Helakit)](https://codecov.io/gh/Aswikinz/Helakit)
48
+ [![Docs](https://img.shields.io/badge/docs-online-blue)](https://Aswikinz.github.io/Helakit/)
49
+ [![License: Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
50
+
51
+ Helakit is a small, dependency-free Python library for validating and
52
+ parsing Sri Lankan identifiers — NIC numbers, phone numbers, postal
53
+ codes, and more. Each identifier lives in its own self-contained
54
+ subpackage and shares a single result type, so adding a new validator
55
+ is a matter of dropping in a folder.
56
+
57
+ For usage and API reference, see the [docs](https://Aswikinz.github.io/Helakit/).
58
+ This page is a tour of *how the project is laid out* — useful if you
59
+ want to contribute, audit, or fork.
60
+
61
+ ## Design principles
62
+
63
+ 1. **Modular monolith.** Every validation domain (`nic`, `phone`,
64
+ `postal`, …) is a self-contained subpackage. Adding a new domain is
65
+ adding a new folder; no plugin system or registry to wire up.
66
+ 2. **Zero runtime dependencies.** The library itself uses only the
67
+ Python standard library. Dev and docs tools are kept in extras.
68
+ 3. **Data as Python dicts.** Lookup tables (provinces, districts,
69
+ mobile prefixes, NIC encoding rules) live as module-level `dict`
70
+ constants in `.py` files, not JSON / Parquet / SQLite. Lookups are
71
+ O(1) and cost nothing after import.
72
+ 4. **One result shape, two entry points.** Every validator exposes
73
+ both a rich `validate_X(value) -> ValidationResult` and a boolean
74
+ `is_valid_X(value) -> bool`. `ValidationResult` is truthy when
75
+ valid, so the rich form drops into `if` statements naturally.
76
+ 5. **`src/` layout.** Tests run against the *installed* package, not
77
+ the source tree, so packaging mistakes can't masquerade as passing
78
+ tests.
79
+ 6. **Strict typing end to end.** A `py.typed` marker ships with the
80
+ wheel and CI runs `mypy --strict`. Type hints use modern syntax
81
+ (`X | Y`, `list[X]`, `dict[K, V]`).
82
+
83
+ ## Repository layout
84
+
85
+ ```text
86
+ src/helakit/
87
+ ├── __init__.py # public API surface + __version__
88
+ ├── py.typed # PEP 561 marker
89
+ ├── _core/ # shared primitives, no domain logic
90
+ │ ├── result.py # ValidationResult + ValidationError dataclasses
91
+ │ ├── base.py # Validator Protocol
92
+ │ └── exceptions.py # HelakitError hierarchy
93
+ ├── _data/ # cross-domain lookup tables (provinces, districts, …)
94
+ └── <domain>/ # one folder per identifier type
95
+ ├── __init__.py # re-exports validate_X / is_valid_X
96
+ ├── validator.py # the actual rules
97
+ ├── exceptions.py # domain-specific exceptions
98
+ └── _data.py # domain-specific lookup tables (optional)
99
+ ```
100
+
101
+ Domains currently in the tree: `nic/`, `phone/`, `postal/`. The
102
+ underscore-prefixed packages (`_core/`, `_data/`) are private —
103
+ nothing outside the package should import from them.
104
+
105
+ Around the source:
106
+
107
+ ```text
108
+ tests/ # mirror of src/helakit/, one folder per domain
109
+ docs/ # MkDocs site (Material theme, mike for versioning)
110
+ .github/workflows/ # ci.yml, docs.yml, release.yml
111
+ pyproject.toml # hatchling build, ruff, mypy, pytest, coverage config
112
+ ```
113
+
114
+ ## How a domain is structured
115
+
116
+ Each domain is independent. The contract:
117
+
118
+ - `validate_X(value: str) -> ValidationResult` — full validation,
119
+ returns parsed fields in `result.data` and structured errors in
120
+ `result.errors`.
121
+ - `is_valid_X(value: str) -> bool` — boolean shorthand.
122
+ - A domain-specific `XError` exception class inheriting from
123
+ `HelakitError`, for unrecoverable misuse (not validation failures —
124
+ those go through `ValidationResult`).
125
+ - A `_data.py` for any tables only that domain cares about.
126
+
127
+ The `__init__.py` re-exports the two functions and the exception, and
128
+ the top-level `helakit/__init__.py` re-exports them again so users can
129
+ write `from helakit import validate_nic` without thinking about layout.
130
+
131
+ ## Validators
132
+
133
+ | Validator | Function | Status |
134
+ | --------- | ----------------- | ----------- |
135
+ | NIC | `validate_nic` | In progress |
136
+ | Phone | `validate_phone` | Planned |
137
+ | Postal | `validate_postal` | Planned |
138
+ | Passport | (planned) | Planned |
139
+ | Vehicle | (planned) | Planned |
140
+
141
+ More (driving licence numbers, BR numbers, …) will follow. Stubs for
142
+ unimplemented validators raise `NotImplementedError` so call-sites
143
+ written against the planned API don't silently no-op.
144
+
145
+ ## Adding a new validator
146
+
147
+ 1. Create `src/helakit/<domain>/` mirroring the layout above.
148
+ 2. Add a `tests/test_<domain>/` folder with at least one test for the
149
+ happy path and one for each error class.
150
+ 3. Add a `docs/validators/<domain>.md` page.
151
+ 4. Re-export the public functions from `src/helakit/__init__.py`.
152
+ 5. Add a `## [Unreleased]` entry to `CHANGELOG.md`.
153
+
154
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the dev-environment setup
155
+ and the PR checklist.
156
+
157
+ ## Data contributions
158
+
159
+ A lot of helakit's value lives in its lookup tables. Adding or
160
+ correcting entries (postal codes, mobile prefixes, district names) is
161
+ the easiest way to contribute and doesn't require deep Python — each
162
+ table is a plain `dict` in `src/helakit/_data/` or
163
+ `src/helakit/<domain>/_data.py`. Cite a source in the PR description
164
+ so we can verify it.
165
+
166
+ ## Documentation
167
+
168
+ Docs are versioned with [mike](https://github.com/jimporter/mike) and
169
+ published in three flavours:
170
+
171
+ - `/dev/` — built from every push to `main`. Tracks in-progress work.
172
+ - `/<MAJOR>.<MINOR>/` — built from each release tag. Frozen.
173
+ - `/latest/` — alias for the most recent release.
174
+
175
+ The bare site URL ([Aswikinz.github.io/Helakit](https://Aswikinz.github.io/Helakit/))
176
+ redirects to `/latest/` once a release exists, and to `/dev/` until then.
177
+
178
+ Links: [docs](https://Aswikinz.github.io/Helakit/) ·
179
+ [dev](https://Aswikinz.github.io/Helakit/dev/) ·
180
+ [changelog](CHANGELOG.md) ·
181
+ [contributing](CONTRIBUTING.md).
182
+
183
+ ## Install
184
+
185
+ ```bash
186
+ pip install helakit
187
+ ```
188
+
189
+ Requires Python 3.10+.
190
+
191
+ ## Status
192
+
193
+ Helakit is alpha software. The public API may change before 1.0; pin
194
+ versions accordingly.
195
+
196
+ ## License
197
+
198
+ Apache License 2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,159 @@
1
+ # Helakit
2
+
3
+ *A toolkit for validating and working with Sri Lankan data.*
4
+
5
+ [![PyPI version](https://img.shields.io/pypi/v/helakit.svg)](https://pypi.org/project/helakit/)
6
+ [![Python versions](https://img.shields.io/pypi/pyversions/helakit.svg)](https://pypi.org/project/helakit/)
7
+ [![CI](https://github.com/Aswikinz/Helakit/actions/workflows/ci.yml/badge.svg)](https://github.com/Aswikinz/Helakit/actions/workflows/ci.yml)
8
+ [![Coverage](https://img.shields.io/codecov/c/github/Aswikinz/Helakit)](https://codecov.io/gh/Aswikinz/Helakit)
9
+ [![Docs](https://img.shields.io/badge/docs-online-blue)](https://Aswikinz.github.io/Helakit/)
10
+ [![License: Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
11
+
12
+ Helakit is a small, dependency-free Python library for validating and
13
+ parsing Sri Lankan identifiers — NIC numbers, phone numbers, postal
14
+ codes, and more. Each identifier lives in its own self-contained
15
+ subpackage and shares a single result type, so adding a new validator
16
+ is a matter of dropping in a folder.
17
+
18
+ For usage and API reference, see the [docs](https://Aswikinz.github.io/Helakit/).
19
+ This page is a tour of *how the project is laid out* — useful if you
20
+ want to contribute, audit, or fork.
21
+
22
+ ## Design principles
23
+
24
+ 1. **Modular monolith.** Every validation domain (`nic`, `phone`,
25
+ `postal`, …) is a self-contained subpackage. Adding a new domain is
26
+ adding a new folder; no plugin system or registry to wire up.
27
+ 2. **Zero runtime dependencies.** The library itself uses only the
28
+ Python standard library. Dev and docs tools are kept in extras.
29
+ 3. **Data as Python dicts.** Lookup tables (provinces, districts,
30
+ mobile prefixes, NIC encoding rules) live as module-level `dict`
31
+ constants in `.py` files, not JSON / Parquet / SQLite. Lookups are
32
+ O(1) and cost nothing after import.
33
+ 4. **One result shape, two entry points.** Every validator exposes
34
+ both a rich `validate_X(value) -> ValidationResult` and a boolean
35
+ `is_valid_X(value) -> bool`. `ValidationResult` is truthy when
36
+ valid, so the rich form drops into `if` statements naturally.
37
+ 5. **`src/` layout.** Tests run against the *installed* package, not
38
+ the source tree, so packaging mistakes can't masquerade as passing
39
+ tests.
40
+ 6. **Strict typing end to end.** A `py.typed` marker ships with the
41
+ wheel and CI runs `mypy --strict`. Type hints use modern syntax
42
+ (`X | Y`, `list[X]`, `dict[K, V]`).
43
+
44
+ ## Repository layout
45
+
46
+ ```text
47
+ src/helakit/
48
+ ├── __init__.py # public API surface + __version__
49
+ ├── py.typed # PEP 561 marker
50
+ ├── _core/ # shared primitives, no domain logic
51
+ │ ├── result.py # ValidationResult + ValidationError dataclasses
52
+ │ ├── base.py # Validator Protocol
53
+ │ └── exceptions.py # HelakitError hierarchy
54
+ ├── _data/ # cross-domain lookup tables (provinces, districts, …)
55
+ └── <domain>/ # one folder per identifier type
56
+ ├── __init__.py # re-exports validate_X / is_valid_X
57
+ ├── validator.py # the actual rules
58
+ ├── exceptions.py # domain-specific exceptions
59
+ └── _data.py # domain-specific lookup tables (optional)
60
+ ```
61
+
62
+ Domains currently in the tree: `nic/`, `phone/`, `postal/`. The
63
+ underscore-prefixed packages (`_core/`, `_data/`) are private —
64
+ nothing outside the package should import from them.
65
+
66
+ Around the source:
67
+
68
+ ```text
69
+ tests/ # mirror of src/helakit/, one folder per domain
70
+ docs/ # MkDocs site (Material theme, mike for versioning)
71
+ .github/workflows/ # ci.yml, docs.yml, release.yml
72
+ pyproject.toml # hatchling build, ruff, mypy, pytest, coverage config
73
+ ```
74
+
75
+ ## How a domain is structured
76
+
77
+ Each domain is independent. The contract:
78
+
79
+ - `validate_X(value: str) -> ValidationResult` — full validation,
80
+ returns parsed fields in `result.data` and structured errors in
81
+ `result.errors`.
82
+ - `is_valid_X(value: str) -> bool` — boolean shorthand.
83
+ - A domain-specific `XError` exception class inheriting from
84
+ `HelakitError`, for unrecoverable misuse (not validation failures —
85
+ those go through `ValidationResult`).
86
+ - A `_data.py` for any tables only that domain cares about.
87
+
88
+ The `__init__.py` re-exports the two functions and the exception, and
89
+ the top-level `helakit/__init__.py` re-exports them again so users can
90
+ write `from helakit import validate_nic` without thinking about layout.
91
+
92
+ ## Validators
93
+
94
+ | Validator | Function | Status |
95
+ | --------- | ----------------- | ----------- |
96
+ | NIC | `validate_nic` | In progress |
97
+ | Phone | `validate_phone` | Planned |
98
+ | Postal | `validate_postal` | Planned |
99
+ | Passport | (planned) | Planned |
100
+ | Vehicle | (planned) | Planned |
101
+
102
+ More (driving licence numbers, BR numbers, …) will follow. Stubs for
103
+ unimplemented validators raise `NotImplementedError` so call-sites
104
+ written against the planned API don't silently no-op.
105
+
106
+ ## Adding a new validator
107
+
108
+ 1. Create `src/helakit/<domain>/` mirroring the layout above.
109
+ 2. Add a `tests/test_<domain>/` folder with at least one test for the
110
+ happy path and one for each error class.
111
+ 3. Add a `docs/validators/<domain>.md` page.
112
+ 4. Re-export the public functions from `src/helakit/__init__.py`.
113
+ 5. Add a `## [Unreleased]` entry to `CHANGELOG.md`.
114
+
115
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the dev-environment setup
116
+ and the PR checklist.
117
+
118
+ ## Data contributions
119
+
120
+ A lot of helakit's value lives in its lookup tables. Adding or
121
+ correcting entries (postal codes, mobile prefixes, district names) is
122
+ the easiest way to contribute and doesn't require deep Python — each
123
+ table is a plain `dict` in `src/helakit/_data/` or
124
+ `src/helakit/<domain>/_data.py`. Cite a source in the PR description
125
+ so we can verify it.
126
+
127
+ ## Documentation
128
+
129
+ Docs are versioned with [mike](https://github.com/jimporter/mike) and
130
+ published in three flavours:
131
+
132
+ - `/dev/` — built from every push to `main`. Tracks in-progress work.
133
+ - `/<MAJOR>.<MINOR>/` — built from each release tag. Frozen.
134
+ - `/latest/` — alias for the most recent release.
135
+
136
+ The bare site URL ([Aswikinz.github.io/Helakit](https://Aswikinz.github.io/Helakit/))
137
+ redirects to `/latest/` once a release exists, and to `/dev/` until then.
138
+
139
+ Links: [docs](https://Aswikinz.github.io/Helakit/) ·
140
+ [dev](https://Aswikinz.github.io/Helakit/dev/) ·
141
+ [changelog](CHANGELOG.md) ·
142
+ [contributing](CONTRIBUTING.md).
143
+
144
+ ## Install
145
+
146
+ ```bash
147
+ pip install helakit
148
+ ```
149
+
150
+ Requires Python 3.10+.
151
+
152
+ ## Status
153
+
154
+ Helakit is alpha software. The public API may change before 1.0; pin
155
+ versions accordingly.
156
+
157
+ ## License
158
+
159
+ Apache License 2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,108 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "helakit"
7
+ description = "A toolkit for validating and working with Sri Lankan data."
8
+ readme = "README.md"
9
+ requires-python = ">=3.10"
10
+ license = "Apache-2.0"
11
+ license-files = ["LICENSE"]
12
+ authors = [{ name = "The helakit authors" }]
13
+ keywords = ["sri-lanka", "validation", "nic", "phone", "postal"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: Apache Software License",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Topic :: Software Development :: Libraries",
24
+ ]
25
+ dynamic = ["version"]
26
+ dependencies = []
27
+
28
+ [project.optional-dependencies]
29
+ dev = [
30
+ "pytest>=8",
31
+ "pytest-cov>=5",
32
+ "hypothesis>=6",
33
+ "mypy>=1.10",
34
+ "ruff>=0.5",
35
+ "pre-commit>=3.7",
36
+ ]
37
+ docs = [
38
+ "mkdocs>=1.6",
39
+ "mkdocs-material>=9.5",
40
+ "mkdocstrings[python]>=0.25",
41
+ "mkdocs-gen-files>=0.5",
42
+ "mkdocs-literate-nav>=0.6",
43
+ "mike>=2.1",
44
+ ]
45
+
46
+ [project.urls]
47
+ Homepage = "https://github.com/Aswikinz/Helakit"
48
+ Documentation = "https://Aswikinz.github.io/Helakit/"
49
+ Repository = "https://github.com/Aswikinz/Helakit"
50
+ Issues = "https://github.com/Aswikinz/Helakit/issues"
51
+ Changelog = "https://github.com/Aswikinz/Helakit/blob/main/CHANGELOG.md"
52
+
53
+ [tool.hatch.version]
54
+ path = "src/helakit/__init__.py"
55
+
56
+ [tool.hatch.build.targets.wheel]
57
+ packages = ["src/helakit"]
58
+
59
+ [tool.hatch.build.targets.sdist]
60
+ include = [
61
+ "src/helakit",
62
+ "tests",
63
+ "README.md",
64
+ "CHANGELOG.md",
65
+ "LICENSE",
66
+ "pyproject.toml",
67
+ ]
68
+
69
+ [tool.ruff]
70
+ line-length = 100
71
+ target-version = "py310"
72
+
73
+ [tool.ruff.lint]
74
+ select = ["E", "F", "I", "UP", "B", "SIM", "RUF"]
75
+
76
+ [tool.ruff.lint.per-file-ignores]
77
+ "tests/**/*.py" = ["B", "SIM"]
78
+
79
+ [tool.ruff.lint.isort]
80
+ known-first-party = ["helakit"]
81
+
82
+ [tool.mypy]
83
+ python_version = "3.10"
84
+ strict = true
85
+ files = ["src"]
86
+ warn_unused_configs = true
87
+
88
+ [[tool.mypy.overrides]]
89
+ module = "helakit.*"
90
+ disallow_any_unimported = true
91
+
92
+ [tool.pytest.ini_options]
93
+ testpaths = ["tests"]
94
+ addopts = "--cov=helakit --cov-report=term-missing --cov-report=xml --strict-markers"
95
+
96
+ [tool.coverage.run]
97
+ branch = true
98
+ source = ["helakit"]
99
+
100
+ [tool.coverage.report]
101
+ fail_under = 90
102
+ show_missing = true
103
+ skip_covered = false
104
+ exclude_also = [
105
+ "raise NotImplementedError",
106
+ "if TYPE_CHECKING:",
107
+ "@overload",
108
+ ]
@@ -0,0 +1,23 @@
1
+ """Helakit — a toolkit for validating and working with Sri Lankan data."""
2
+
3
+ from helakit._core.exceptions import HelakitError, InvalidInputError
4
+ from helakit._core.result import ValidationError, ValidationResult
5
+ from helakit.nic import is_valid_nic, validate_nic
6
+ from helakit.phone import is_valid_phone, validate_phone
7
+ from helakit.postal import is_valid_postal, validate_postal
8
+
9
+ __version__ = "0.1.0"
10
+
11
+ __all__ = [
12
+ "HelakitError",
13
+ "InvalidInputError",
14
+ "ValidationError",
15
+ "ValidationResult",
16
+ "__version__",
17
+ "is_valid_nic",
18
+ "is_valid_phone",
19
+ "is_valid_postal",
20
+ "validate_nic",
21
+ "validate_phone",
22
+ "validate_postal",
23
+ ]
@@ -0,0 +1,13 @@
1
+ """Core primitives: ``ValidationResult``, the ``Validator`` protocol, and exceptions."""
2
+
3
+ from helakit._core.base import Validator
4
+ from helakit._core.exceptions import HelakitError, InvalidInputError
5
+ from helakit._core.result import ValidationError, ValidationResult
6
+
7
+ __all__ = [
8
+ "HelakitError",
9
+ "InvalidInputError",
10
+ "ValidationError",
11
+ "ValidationResult",
12
+ "Validator",
13
+ ]
@@ -0,0 +1,28 @@
1
+ """The ``Validator`` protocol that every domain validator implements."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Protocol, runtime_checkable
6
+
7
+ from helakit._core.result import ValidationResult
8
+
9
+
10
+ @runtime_checkable
11
+ class Validator(Protocol):
12
+ """Structural type for any object that validates Sri Lankan data.
13
+
14
+ Implementations expose a short ``name`` (e.g. ``"nic"``) along with two
15
+ parallel entry points: a rich :meth:`validate` returning a
16
+ :class:`~helakit._core.result.ValidationResult`, and a boolean
17
+ :meth:`is_valid` shorthand.
18
+ """
19
+
20
+ name: str
21
+
22
+ def validate(self, value: str) -> ValidationResult:
23
+ """Run full validation and return a structured result."""
24
+ ...
25
+
26
+ def is_valid(self, value: str) -> bool:
27
+ """Return ``True`` if ``value`` is valid, ``False`` otherwise."""
28
+ ...
@@ -0,0 +1,21 @@
1
+ """Exception hierarchy for programmer errors raised by helakit.
2
+
3
+ Validation *failures* are reported through :class:`ValidationResult` rather
4
+ than exceptions; the classes here represent unrecoverable misuse — for
5
+ example, passing ``None`` where a string is required.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+
11
+ class HelakitError(Exception):
12
+ """Base class for every exception raised by helakit."""
13
+
14
+
15
+ class InvalidInputError(HelakitError):
16
+ """Raised when an input is the wrong type or otherwise unusable.
17
+
18
+ This signals a programmer error, not a validation failure. A malformed
19
+ NIC string returns a :class:`ValidationResult` with ``is_valid=False``;
20
+ passing ``None`` instead of a string raises this.
21
+ """
@@ -0,0 +1,53 @@
1
+ """Result types returned by every validator."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass, field
6
+ from typing import Any
7
+
8
+
9
+ @dataclass(frozen=True, slots=True)
10
+ class ValidationError:
11
+ """A single validation failure.
12
+
13
+ Attributes:
14
+ code: A short machine-readable identifier (e.g. ``"nic.bad_checksum"``).
15
+ message: A human-readable description of what went wrong.
16
+ field: The specific field within the input that failed, if applicable.
17
+ """
18
+
19
+ code: str
20
+ message: str
21
+ field: str | None = None
22
+
23
+
24
+ @dataclass(frozen=True, slots=True)
25
+ class ValidationResult:
26
+ """The outcome of validating a single value.
27
+
28
+ Attributes:
29
+ is_valid: ``True`` if the input passed every check.
30
+ value: The original input string, unmodified.
31
+ normalized: The canonical representation of ``value`` when valid.
32
+ errors: Every error encountered. Empty when ``is_valid`` is ``True``.
33
+ data: Structured fields extracted during validation (e.g. NIC date of
34
+ birth, gender). Empty when no fields could be extracted.
35
+ """
36
+
37
+ is_valid: bool
38
+ value: str
39
+ normalized: str | None = None
40
+ errors: list[ValidationError] = field(default_factory=list)
41
+ data: dict[str, Any] = field(default_factory=dict)
42
+
43
+ def __bool__(self) -> bool:
44
+ return self.is_valid
45
+
46
+ def __repr__(self) -> str:
47
+ if self.is_valid:
48
+ return (
49
+ f"ValidationResult(is_valid=True, value={self.value!r}, "
50
+ f"normalized={self.normalized!r}, data={self.data!r})"
51
+ )
52
+ codes = [e.code for e in self.errors]
53
+ return f"ValidationResult(is_valid=False, value={self.value!r}, errors={codes!r})"
@@ -0,0 +1,5 @@
1
+ """Static lookup tables used across validators.
2
+
3
+ Every entry here is a plain Python ``dict`` constant living in its own
4
+ module. Importing the package is essentially free; lookups are O(1).
5
+ """
@@ -0,0 +1,15 @@
1
+ """Districts of Sri Lanka, keyed by short code.
2
+
3
+ Placeholder data — the remaining districts will be added alongside the
4
+ postal-code validator.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from typing import Final
10
+
11
+ DISTRICTS: Final[dict[str, str]] = {
12
+ "CMB": "Colombo",
13
+ "KAN": "Kandy",
14
+ "GAL": "Galle",
15
+ }
@@ -0,0 +1,15 @@
1
+ """Provinces of Sri Lanka, keyed by short code.
2
+
3
+ Placeholder data — the remaining provinces will be added alongside the
4
+ postal-code validator.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from typing import Final
10
+
11
+ PROVINCES: Final[dict[str, str]] = {
12
+ "WP": "Western",
13
+ "CP": "Central",
14
+ "SP": "Southern",
15
+ }
@@ -0,0 +1,10 @@
1
+ """NIC (National Identity Card) validation."""
2
+
3
+ from helakit.nic.exceptions import NICError
4
+ from helakit.nic.validator import is_valid_nic, validate_nic
5
+
6
+ __all__ = [
7
+ "NICError",
8
+ "is_valid_nic",
9
+ "validate_nic",
10
+ ]
@@ -0,0 +1,18 @@
1
+ """Constants used while decoding NIC numbers.
2
+
3
+ Sri Lankan NICs encode the holder's date of birth as the day-of-year, with
4
+ female DOBs offset by 500. Old-format NICs use a two-digit year and end in
5
+ a letter (V/X) for voting eligibility; new-format NICs are fully numeric
6
+ and use a four-digit year. The exact encoding rules will live here.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from typing import Final
12
+
13
+ OLD_FORMAT_LENGTH: Final[int] = 10
14
+ NEW_FORMAT_LENGTH: Final[int] = 12
15
+
16
+ FEMALE_DAY_OFFSET: Final[int] = 500
17
+
18
+ OLD_FORMAT_SUFFIXES: Final[frozenset[str]] = frozenset({"V", "X"})
@@ -0,0 +1,9 @@
1
+ """NIC-specific exceptions."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from helakit._core.exceptions import HelakitError
6
+
7
+
8
+ class NICError(HelakitError):
9
+ """Raised for unrecoverable NIC-related programmer errors."""
@@ -0,0 +1,38 @@
1
+ """NIC validation entry points.
2
+
3
+ Both :func:`validate_nic` and :func:`is_valid_nic` are stubs for now and
4
+ will be implemented in a follow-up release.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from helakit._core.result import ValidationResult
10
+
11
+
12
+ def validate_nic(value: str) -> ValidationResult:
13
+ """Validate a Sri Lankan NIC number and return a structured result.
14
+
15
+ Args:
16
+ value: The NIC number as a string. Both old (e.g. ``"901234567V"``)
17
+ and new (e.g. ``"199012345678"``) formats will be accepted.
18
+
19
+ Returns:
20
+ A :class:`ValidationResult` with parsed fields (date of birth,
21
+ gender, voting eligibility, …) populated when valid.
22
+
23
+ Raises:
24
+ NotImplementedError: NIC validation has not been implemented yet.
25
+ """
26
+ raise NotImplementedError("Coming in a future release")
27
+
28
+
29
+ def is_valid_nic(value: str) -> bool:
30
+ """Return ``True`` if ``value`` is a valid Sri Lankan NIC number.
31
+
32
+ Args:
33
+ value: The NIC number as a string.
34
+
35
+ Raises:
36
+ NotImplementedError: NIC validation has not been implemented yet.
37
+ """
38
+ raise NotImplementedError("Coming in a future release")
@@ -0,0 +1,10 @@
1
+ """Sri Lankan phone-number validation."""
2
+
3
+ from helakit.phone.exceptions import PhoneError
4
+ from helakit.phone.validator import is_valid_phone, validate_phone
5
+
6
+ __all__ = [
7
+ "PhoneError",
8
+ "is_valid_phone",
9
+ "validate_phone",
10
+ ]
@@ -0,0 +1,9 @@
1
+ """Phone-specific exceptions."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from helakit._core.exceptions import HelakitError
6
+
7
+
8
+ class PhoneError(HelakitError):
9
+ """Raised for unrecoverable phone-related programmer errors."""
@@ -0,0 +1,31 @@
1
+ """Phone-number validation entry points (stub)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from helakit._core.result import ValidationResult
6
+
7
+
8
+ def validate_phone(value: str) -> ValidationResult:
9
+ """Validate a Sri Lankan phone number.
10
+
11
+ Args:
12
+ value: The phone number, either local (``"0712345678"``) or
13
+ international (``"+94712345678"``) form.
14
+
15
+ Returns:
16
+ A :class:`ValidationResult` with the carrier and number type
17
+ populated when valid.
18
+
19
+ Raises:
20
+ NotImplementedError: Phone validation has not been implemented yet.
21
+ """
22
+ raise NotImplementedError("Coming in a future release")
23
+
24
+
25
+ def is_valid_phone(value: str) -> bool:
26
+ """Return ``True`` if ``value`` is a valid Sri Lankan phone number.
27
+
28
+ Raises:
29
+ NotImplementedError: Phone validation has not been implemented yet.
30
+ """
31
+ raise NotImplementedError("Coming in a future release")
@@ -0,0 +1,10 @@
1
+ """Sri Lankan postal-code validation."""
2
+
3
+ from helakit.postal.exceptions import PostalError
4
+ from helakit.postal.validator import is_valid_postal, validate_postal
5
+
6
+ __all__ = [
7
+ "PostalError",
8
+ "is_valid_postal",
9
+ "validate_postal",
10
+ ]
@@ -0,0 +1,9 @@
1
+ """Postal-code-specific exceptions."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from helakit._core.exceptions import HelakitError
6
+
7
+
8
+ class PostalError(HelakitError):
9
+ """Raised for unrecoverable postal-code-related programmer errors."""
@@ -0,0 +1,30 @@
1
+ """Postal-code validation entry points (stub)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from helakit._core.result import ValidationResult
6
+
7
+
8
+ def validate_postal(value: str) -> ValidationResult:
9
+ """Validate a Sri Lankan postal code.
10
+
11
+ Args:
12
+ value: A five-digit postal code.
13
+
14
+ Returns:
15
+ A :class:`ValidationResult` with the matching district and
16
+ province populated when valid.
17
+
18
+ Raises:
19
+ NotImplementedError: Postal-code validation has not been implemented yet.
20
+ """
21
+ raise NotImplementedError("Coming in a future release")
22
+
23
+
24
+ def is_valid_postal(value: str) -> bool:
25
+ """Return ``True`` if ``value`` is a valid Sri Lankan postal code.
26
+
27
+ Raises:
28
+ NotImplementedError: Postal-code validation has not been implemented yet.
29
+ """
30
+ raise NotImplementedError("Coming in a future release")
File without changes
File without changes
@@ -0,0 +1,5 @@
1
+ """Shared pytest fixtures.
2
+
3
+ Currently empty — added so domain-specific conftests have a parent and so
4
+ pytest's rootdir resolution stays predictable.
5
+ """
File without changes
@@ -0,0 +1,29 @@
1
+ """Smoke tests for the static lookup tables."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from helakit._data.districts import DISTRICTS
6
+ from helakit._data.provinces import PROVINCES
7
+ from helakit.nic._data import (
8
+ FEMALE_DAY_OFFSET,
9
+ NEW_FORMAT_LENGTH,
10
+ OLD_FORMAT_LENGTH,
11
+ OLD_FORMAT_SUFFIXES,
12
+ )
13
+
14
+
15
+ def test_provinces_table_has_entries() -> None:
16
+ assert PROVINCES
17
+ assert all(isinstance(k, str) and isinstance(v, str) for k, v in PROVINCES.items())
18
+
19
+
20
+ def test_districts_table_has_entries() -> None:
21
+ assert DISTRICTS
22
+ assert all(isinstance(k, str) and isinstance(v, str) for k, v in DISTRICTS.items())
23
+
24
+
25
+ def test_nic_format_constants() -> None:
26
+ assert OLD_FORMAT_LENGTH == 10
27
+ assert NEW_FORMAT_LENGTH == 12
28
+ assert FEMALE_DAY_OFFSET == 500
29
+ assert OLD_FORMAT_SUFFIXES == frozenset({"V", "X"})
@@ -0,0 +1,60 @@
1
+ """Tests for :class:`ValidationResult` and :class:`ValidationError`."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import pytest
6
+
7
+ from helakit import ValidationError, ValidationResult
8
+
9
+
10
+ def test_valid_result_is_truthy() -> None:
11
+ result = ValidationResult(is_valid=True, value="x", normalized="X")
12
+ assert result
13
+ assert bool(result) is True
14
+
15
+
16
+ def test_invalid_result_is_falsy() -> None:
17
+ result = ValidationResult(
18
+ is_valid=False,
19
+ value="x",
20
+ errors=[ValidationError(code="bad", message="nope")],
21
+ )
22
+ assert not result
23
+ assert bool(result) is False
24
+
25
+
26
+ def test_default_collections_are_independent() -> None:
27
+ a = ValidationResult(is_valid=True, value="a")
28
+ b = ValidationResult(is_valid=True, value="b")
29
+ assert a.errors is not b.errors
30
+ assert a.data is not b.data
31
+
32
+
33
+ def test_repr_distinguishes_valid_from_invalid() -> None:
34
+ valid = ValidationResult(is_valid=True, value="x", normalized="X", data={"k": 1})
35
+ invalid = ValidationResult(
36
+ is_valid=False,
37
+ value="x",
38
+ errors=[ValidationError(code="bad", message="nope")],
39
+ )
40
+ assert "is_valid=True" in repr(valid)
41
+ assert "'k': 1" in repr(valid)
42
+ assert "is_valid=False" in repr(invalid)
43
+ assert "'bad'" in repr(invalid)
44
+
45
+
46
+ def test_result_is_frozen() -> None:
47
+ result = ValidationResult(is_valid=True, value="x")
48
+ with pytest.raises(AttributeError):
49
+ result.is_valid = False # type: ignore[misc]
50
+
51
+
52
+ def test_error_is_frozen() -> None:
53
+ error = ValidationError(code="bad", message="nope")
54
+ with pytest.raises(AttributeError):
55
+ error.code = "other" # type: ignore[misc]
56
+
57
+
58
+ def test_error_field_defaults_to_none() -> None:
59
+ error = ValidationError(code="bad", message="nope")
60
+ assert error.field is None
File without changes
@@ -0,0 +1,17 @@
1
+ """Placeholder tests for the NIC validator stubs."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import pytest
6
+
7
+ from helakit import is_valid_nic, validate_nic
8
+
9
+
10
+ def test_validate_nic_is_stubbed() -> None:
11
+ with pytest.raises(NotImplementedError):
12
+ validate_nic("199012345678")
13
+
14
+
15
+ def test_is_valid_nic_is_stubbed() -> None:
16
+ with pytest.raises(NotImplementedError):
17
+ is_valid_nic("199012345678")
File without changes
@@ -0,0 +1,17 @@
1
+ """Placeholder tests for the phone validator stubs."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import pytest
6
+
7
+ from helakit import is_valid_phone, validate_phone
8
+
9
+
10
+ def test_validate_phone_is_stubbed() -> None:
11
+ with pytest.raises(NotImplementedError):
12
+ validate_phone("0712345678")
13
+
14
+
15
+ def test_is_valid_phone_is_stubbed() -> None:
16
+ with pytest.raises(NotImplementedError):
17
+ is_valid_phone("0712345678")
File without changes
@@ -0,0 +1,17 @@
1
+ """Placeholder tests for the postal-code validator stubs."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import pytest
6
+
7
+ from helakit import is_valid_postal, validate_postal
8
+
9
+
10
+ def test_validate_postal_is_stubbed() -> None:
11
+ with pytest.raises(NotImplementedError):
12
+ validate_postal("10100")
13
+
14
+
15
+ def test_is_valid_postal_is_stubbed() -> None:
16
+ with pytest.raises(NotImplementedError):
17
+ is_valid_postal("10100")