simplibs-types 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 (158) hide show
  1. simplibs_types-0.1.0/LICENSE +21 -0
  2. simplibs_types-0.1.0/PKG-INFO +429 -0
  3. simplibs_types-0.1.0/README.md +400 -0
  4. simplibs_types-0.1.0/pyproject.toml +60 -0
  5. simplibs_types-0.1.0/setup.cfg +4 -0
  6. simplibs_types-0.1.0/src/simplibs/types/__init__.py +285 -0
  7. simplibs_types-0.1.0/src/simplibs/types/collections/__init__.py +18 -0
  8. simplibs_types-0.1.0/src/simplibs/types/collections/dict/__init__.py +24 -0
  9. simplibs_types-0.1.0/src/simplibs/types/collections/dict/direct/__init__.py +0 -0
  10. simplibs_types-0.1.0/src/simplibs/types/collections/dict/direct/dict_not_empty.py +18 -0
  11. simplibs_types-0.1.0/src/simplibs/types/collections/dict/parametrized/__init__.py +0 -0
  12. simplibs_types-0.1.0/src/simplibs/types/collections/dict/parametrized/dict_length.py +23 -0
  13. simplibs_types-0.1.0/src/simplibs/types/collections/dict/parametrized/dict_max_length.py +23 -0
  14. simplibs_types-0.1.0/src/simplibs/types/collections/dict/parametrized/dict_min_length.py +23 -0
  15. simplibs_types-0.1.0/src/simplibs/types/collections/list/__init__.py +30 -0
  16. simplibs_types-0.1.0/src/simplibs/types/collections/list/direct/__init__.py +0 -0
  17. simplibs_types-0.1.0/src/simplibs/types/collections/list/direct/list_not_empty.py +18 -0
  18. simplibs_types-0.1.0/src/simplibs/types/collections/list/direct/list_unique.py +18 -0
  19. simplibs_types-0.1.0/src/simplibs/types/collections/list/direct/list_unique_not_empty.py +19 -0
  20. simplibs_types-0.1.0/src/simplibs/types/collections/list/parametrized/__init__.py +0 -0
  21. simplibs_types-0.1.0/src/simplibs/types/collections/list/parametrized/list_length.py +22 -0
  22. simplibs_types-0.1.0/src/simplibs/types/collections/list/parametrized/list_max_length.py +23 -0
  23. simplibs_types-0.1.0/src/simplibs/types/collections/list/parametrized/list_min_length.py +23 -0
  24. simplibs_types-0.1.0/src/simplibs/types/collections/list/parametrized/list_of.py +30 -0
  25. simplibs_types-0.1.0/src/simplibs/types/collections/set/__init__.py +26 -0
  26. simplibs_types-0.1.0/src/simplibs/types/collections/set/direct/__init__.py +0 -0
  27. simplibs_types-0.1.0/src/simplibs/types/collections/set/direct/set_not_empty.py +18 -0
  28. simplibs_types-0.1.0/src/simplibs/types/collections/set/parametrized/__init__.py +0 -0
  29. simplibs_types-0.1.0/src/simplibs/types/collections/set/parametrized/set_length.py +22 -0
  30. simplibs_types-0.1.0/src/simplibs/types/collections/set/parametrized/set_max_length.py +23 -0
  31. simplibs_types-0.1.0/src/simplibs/types/collections/set/parametrized/set_min_length.py +23 -0
  32. simplibs_types-0.1.0/src/simplibs/types/collections/set/parametrized/set_of.py +31 -0
  33. simplibs_types-0.1.0/src/simplibs/types/collections/tuple/__init__.py +26 -0
  34. simplibs_types-0.1.0/src/simplibs/types/collections/tuple/direct/__init__.py +0 -0
  35. simplibs_types-0.1.0/src/simplibs/types/collections/tuple/direct/tuple_not_empty.py +18 -0
  36. simplibs_types-0.1.0/src/simplibs/types/collections/tuple/parametrized/__init__.py +0 -0
  37. simplibs_types-0.1.0/src/simplibs/types/collections/tuple/parametrized/tuple_length.py +22 -0
  38. simplibs_types-0.1.0/src/simplibs/types/collections/tuple/parametrized/tuple_max_length.py +23 -0
  39. simplibs_types-0.1.0/src/simplibs/types/collections/tuple/parametrized/tuple_min_length.py +23 -0
  40. simplibs_types-0.1.0/src/simplibs/types/collections/tuple/parametrized/tuple_of.py +32 -0
  41. simplibs_types-0.1.0/src/simplibs/types/primitives/__init__.py +20 -0
  42. simplibs_types-0.1.0/src/simplibs/types/primitives/bool/__init__.py +18 -0
  43. simplibs_types-0.1.0/src/simplibs/types/primitives/bool/direct/__init__.py +0 -0
  44. simplibs_types-0.1.0/src/simplibs/types/primitives/bool/direct/bool_false.py +18 -0
  45. simplibs_types-0.1.0/src/simplibs/types/primitives/bool/direct/bool_true.py +18 -0
  46. simplibs_types-0.1.0/src/simplibs/types/primitives/bytes/__init__.py +28 -0
  47. simplibs_types-0.1.0/src/simplibs/types/primitives/bytes/direct/__init__.py +0 -0
  48. simplibs_types-0.1.0/src/simplibs/types/primitives/bytes/direct/bytes_empty.py +18 -0
  49. simplibs_types-0.1.0/src/simplibs/types/primitives/bytes/direct/bytes_not_empty.py +18 -0
  50. simplibs_types-0.1.0/src/simplibs/types/primitives/bytes/parametrized/__init__.py +0 -0
  51. simplibs_types-0.1.0/src/simplibs/types/primitives/bytes/parametrized/bytes_length.py +22 -0
  52. simplibs_types-0.1.0/src/simplibs/types/primitives/bytes/parametrized/bytes_length_range.py +25 -0
  53. simplibs_types-0.1.0/src/simplibs/types/primitives/bytes/parametrized/bytes_max_length.py +23 -0
  54. simplibs_types-0.1.0/src/simplibs/types/primitives/bytes/parametrized/bytes_min_length.py +23 -0
  55. simplibs_types-0.1.0/src/simplibs/types/primitives/float/__init__.py +53 -0
  56. simplibs_types-0.1.0/src/simplibs/types/primitives/float/direct/__init__.py +0 -0
  57. simplibs_types-0.1.0/src/simplibs/types/primitives/float/direct/float_finite.py +18 -0
  58. simplibs_types-0.1.0/src/simplibs/types/primitives/float/direct/float_latitude.py +18 -0
  59. simplibs_types-0.1.0/src/simplibs/types/primitives/float/direct/float_longitude.py +18 -0
  60. simplibs_types-0.1.0/src/simplibs/types/primitives/float/direct/float_negative.py +18 -0
  61. simplibs_types-0.1.0/src/simplibs/types/primitives/float/direct/float_non_negative.py +18 -0
  62. simplibs_types-0.1.0/src/simplibs/types/primitives/float/direct/float_non_positive.py +18 -0
  63. simplibs_types-0.1.0/src/simplibs/types/primitives/float/direct/float_not_infinite.py +23 -0
  64. simplibs_types-0.1.0/src/simplibs/types/primitives/float/direct/float_not_nan.py +23 -0
  65. simplibs_types-0.1.0/src/simplibs/types/primitives/float/direct/float_not_zero.py +18 -0
  66. simplibs_types-0.1.0/src/simplibs/types/primitives/float/direct/float_percentage.py +18 -0
  67. simplibs_types-0.1.0/src/simplibs/types/primitives/float/direct/float_positive.py +18 -0
  68. simplibs_types-0.1.0/src/simplibs/types/primitives/float/direct/float_probability.py +18 -0
  69. simplibs_types-0.1.0/src/simplibs/types/primitives/float/direct/float_zero.py +18 -0
  70. simplibs_types-0.1.0/src/simplibs/types/primitives/float/parametrized/__init__.py +0 -0
  71. simplibs_types-0.1.0/src/simplibs/types/primitives/float/parametrized/float_ge.py +22 -0
  72. simplibs_types-0.1.0/src/simplibs/types/primitives/float/parametrized/float_gt.py +22 -0
  73. simplibs_types-0.1.0/src/simplibs/types/primitives/float/parametrized/float_in_range.py +23 -0
  74. simplibs_types-0.1.0/src/simplibs/types/primitives/float/parametrized/float_le.py +22 -0
  75. simplibs_types-0.1.0/src/simplibs/types/primitives/float/parametrized/float_lt.py +22 -0
  76. simplibs_types-0.1.0/src/simplibs/types/primitives/int/__init__.py +77 -0
  77. simplibs_types-0.1.0/src/simplibs/types/primitives/int/direct/__init__.py +0 -0
  78. simplibs_types-0.1.0/src/simplibs/types/primitives/int/direct/int_day_of_month.py +24 -0
  79. simplibs_types-0.1.0/src/simplibs/types/primitives/int/direct/int_even.py +18 -0
  80. simplibs_types-0.1.0/src/simplibs/types/primitives/int/direct/int_hour.py +18 -0
  81. simplibs_types-0.1.0/src/simplibs/types/primitives/int/direct/int_int8.py +18 -0
  82. simplibs_types-0.1.0/src/simplibs/types/primitives/int/direct/int_minute.py +18 -0
  83. simplibs_types-0.1.0/src/simplibs/types/primitives/int/direct/int_month.py +18 -0
  84. simplibs_types-0.1.0/src/simplibs/types/primitives/int/direct/int_negative.py +18 -0
  85. simplibs_types-0.1.0/src/simplibs/types/primitives/int/direct/int_non_negative.py +18 -0
  86. simplibs_types-0.1.0/src/simplibs/types/primitives/int/direct/int_non_negative_even.py +19 -0
  87. simplibs_types-0.1.0/src/simplibs/types/primitives/int/direct/int_non_positive.py +18 -0
  88. simplibs_types-0.1.0/src/simplibs/types/primitives/int/direct/int_not_zero.py +18 -0
  89. simplibs_types-0.1.0/src/simplibs/types/primitives/int/direct/int_odd.py +18 -0
  90. simplibs_types-0.1.0/src/simplibs/types/primitives/int/direct/int_percentage.py +18 -0
  91. simplibs_types-0.1.0/src/simplibs/types/primitives/int/direct/int_port.py +18 -0
  92. simplibs_types-0.1.0/src/simplibs/types/primitives/int/direct/int_positive.py +18 -0
  93. simplibs_types-0.1.0/src/simplibs/types/primitives/int/direct/int_positive_even.py +19 -0
  94. simplibs_types-0.1.0/src/simplibs/types/primitives/int/direct/int_positive_odd.py +19 -0
  95. simplibs_types-0.1.0/src/simplibs/types/primitives/int/direct/int_second.py +22 -0
  96. simplibs_types-0.1.0/src/simplibs/types/primitives/int/direct/int_uint8.py +18 -0
  97. simplibs_types-0.1.0/src/simplibs/types/primitives/int/direct/int_year.py +18 -0
  98. simplibs_types-0.1.0/src/simplibs/types/primitives/int/direct/int_zero.py +18 -0
  99. simplibs_types-0.1.0/src/simplibs/types/primitives/int/parametrized/__init__.py +0 -0
  100. simplibs_types-0.1.0/src/simplibs/types/primitives/int/parametrized/int_divisible_by.py +22 -0
  101. simplibs_types-0.1.0/src/simplibs/types/primitives/int/parametrized/int_eq.py +22 -0
  102. simplibs_types-0.1.0/src/simplibs/types/primitives/int/parametrized/int_ge.py +23 -0
  103. simplibs_types-0.1.0/src/simplibs/types/primitives/int/parametrized/int_gt.py +22 -0
  104. simplibs_types-0.1.0/src/simplibs/types/primitives/int/parametrized/int_in_range.py +23 -0
  105. simplibs_types-0.1.0/src/simplibs/types/primitives/int/parametrized/int_le.py +22 -0
  106. simplibs_types-0.1.0/src/simplibs/types/primitives/int/parametrized/int_lt.py +22 -0
  107. simplibs_types-0.1.0/src/simplibs/types/primitives/int/parametrized/int_multiple_of.py +29 -0
  108. simplibs_types-0.1.0/src/simplibs/types/primitives/int/parametrized/int_ne.py +22 -0
  109. simplibs_types-0.1.0/src/simplibs/types/primitives/int_float/__init__.py +32 -0
  110. simplibs_types-0.1.0/src/simplibs/types/primitives/int_float/direct/__init__.py +0 -0
  111. simplibs_types-0.1.0/src/simplibs/types/primitives/int_float/direct/int_float_finite.py +25 -0
  112. simplibs_types-0.1.0/src/simplibs/types/primitives/int_float/direct/int_float_negative.py +19 -0
  113. simplibs_types-0.1.0/src/simplibs/types/primitives/int_float/direct/int_float_non_negative.py +19 -0
  114. simplibs_types-0.1.0/src/simplibs/types/primitives/int_float/direct/int_float_non_positive.py +19 -0
  115. simplibs_types-0.1.0/src/simplibs/types/primitives/int_float/direct/int_float_not_zero.py +18 -0
  116. simplibs_types-0.1.0/src/simplibs/types/primitives/int_float/direct/int_float_positive.py +19 -0
  117. simplibs_types-0.1.0/src/simplibs/types/primitives/int_float/direct/int_float_zero.py +18 -0
  118. simplibs_types-0.1.0/src/simplibs/types/primitives/int_float/parametrized/__init__.py +0 -0
  119. simplibs_types-0.1.0/src/simplibs/types/primitives/int_float/parametrized/int_float_in_range.py +23 -0
  120. simplibs_types-0.1.0/src/simplibs/types/primitives/str/__init__.py +79 -0
  121. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/__init__.py +0 -0
  122. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/str_alnum.py +20 -0
  123. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/str_alpha.py +19 -0
  124. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/str_ascii.py +18 -0
  125. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/str_blank.py +18 -0
  126. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/str_digit.py +18 -0
  127. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/str_email.py +24 -0
  128. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/str_empty.py +18 -0
  129. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/str_hex_color.py +19 -0
  130. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/str_identifier.py +18 -0
  131. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/str_lower.py +18 -0
  132. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/str_no_whitespace.py +19 -0
  133. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/str_not_blank.py +19 -0
  134. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/str_not_empty.py +23 -0
  135. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/str_printable.py +20 -0
  136. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/str_single_line.py +19 -0
  137. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/str_slug.py +20 -0
  138. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/str_snake_case.py +21 -0
  139. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/str_title.py +18 -0
  140. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/str_upper.py +18 -0
  141. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/str_url.py +23 -0
  142. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/str_uuid.py +19 -0
  143. simplibs_types-0.1.0/src/simplibs/types/primitives/str/direct/str_whitespace.py +20 -0
  144. simplibs_types-0.1.0/src/simplibs/types/primitives/str/parametrized/__init__.py +0 -0
  145. simplibs_types-0.1.0/src/simplibs/types/primitives/str/parametrized/str_contains.py +23 -0
  146. simplibs_types-0.1.0/src/simplibs/types/primitives/str/parametrized/str_ends_with.py +22 -0
  147. simplibs_types-0.1.0/src/simplibs/types/primitives/str/parametrized/str_length.py +23 -0
  148. simplibs_types-0.1.0/src/simplibs/types/primitives/str/parametrized/str_length_range.py +25 -0
  149. simplibs_types-0.1.0/src/simplibs/types/primitives/str/parametrized/str_matches.py +23 -0
  150. simplibs_types-0.1.0/src/simplibs/types/primitives/str/parametrized/str_max_length.py +23 -0
  151. simplibs_types-0.1.0/src/simplibs/types/primitives/str/parametrized/str_min_length.py +23 -0
  152. simplibs_types-0.1.0/src/simplibs/types/primitives/str/parametrized/str_one_of.py +23 -0
  153. simplibs_types-0.1.0/src/simplibs/types/primitives/str/parametrized/str_starts_with.py +22 -0
  154. simplibs_types-0.1.0/src/simplibs_types.egg-info/PKG-INFO +429 -0
  155. simplibs_types-0.1.0/src/simplibs_types.egg-info/SOURCES.txt +156 -0
  156. simplibs_types-0.1.0/src/simplibs_types.egg-info/dependency_links.txt +1 -0
  157. simplibs_types-0.1.0/src/simplibs_types.egg-info/requires.txt +6 -0
  158. simplibs_types-0.1.0/src/simplibs_types.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Dalibor Sova (Sudip2708)
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,429 @@
1
+ Metadata-Version: 2.4
2
+ Name: simplibs-types
3
+ Version: 0.1.0
4
+ Summary: Named, reusable validated types — ready-made presets built on simplibs-rules.
5
+ Author-email: "Dalibor Sova (Sudip2708)" <daliborsova@seznam.cz>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/simplibs/simplibs-types
8
+ Project-URL: Repository, https://github.com/simplibs/simplibs-types
9
+ Project-URL: Issues, https://github.com/simplibs/simplibs-types/issues
10
+ Project-URL: Changelog, https://github.com/simplibs/simplibs-types/blob/main/CHANGELOG.md
11
+ Keywords: validation,validated-types,type-hints,annotated,presets,data-validation,simplibs,simplibs-types,developer-tools
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Classifier: Topic :: Software Development :: Testing
20
+ Requires-Python: >=3.11
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: simplibs-rules>=0.2.2
24
+ Requires-Dist: simplibs-exception>=1.1.3
25
+ Requires-Dist: simplibs-validate>=0.2.1
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=7.0; extra == "dev"
28
+ Dynamic: license-file
29
+
30
+ # 🧩 `simplibs-types`
31
+
32
+ [![PyPI](https://img.shields.io/pypi/v/simplibs-types)](https://pypi.org/project/simplibs-types/)
33
+ [![Python](https://img.shields.io/badge/python-3.11%2B-blue)](https://www.python.org/downloads/)
34
+ [![Licence](https://img.shields.io/badge/licence-MIT-green)](https://github.com/simplibs/simplibs-types/blob/main/LICENSE)
35
+
36
+ **Named, reusable validated types — a pure type-definition library, built on
37
+ [`simplibs-rules`](https://pypi.org/project/simplibs-rules/) and depending on
38
+ [`simplibs-validate`](https://pypi.org/project/simplibs-validate/) for the
39
+ `validated_type()` builder itself.**
40
+
41
+ A `Rule` from `simplibs-rules` answers "does this value satisfy me?". `simplibs-validate`
42
+ provides the `validated_type()` helper, which names a `type_ + rule(s)` combination once,
43
+ as an ordinary `Annotated` type. `simplibs-types` is built exclusively on top of that: it's
44
+ a catalog of ready-made, documented, composed types for the constraints that come up again
45
+ and again — instead of repeating `Annotated[int, greater_than(0)]` by hand at every call
46
+ site.
47
+
48
+ ```python
49
+ from simplibs.types import int_positive, str_email
50
+ from simplibs.validate import validate_call
51
+
52
+ @validate_call
53
+ def register(age: int_positive, email: str_email) -> None:
54
+ ...
55
+
56
+ register(25, "user@example.com") # validated automatically
57
+ register(-5, "not-an-email") # raises ValidationError
58
+ ```
59
+
60
+ Every type ships with its own docstring, so it stays self-explanatory on hover — no
61
+ need to open a browser tab just to remember what `int_uint8` means.
62
+
63
+ ---
64
+
65
+ ## 🧭 The Core Philosophy
66
+
67
+ `simplibs-types` defines nothing new at the rule level — every constraint it enforces
68
+ comes straight from [`simplibs-rules`](https://pypi.org/project/simplibs-rules/). What
69
+ it adds is *naming*: a library of ready-made, documented, composed types for the
70
+ constraints that come up again and again (`int_positive`, `dict_not_empty`,
71
+ `str_email`, ...), all of them built on top of `validated_type()` — the single helper
72
+ that lives in [`simplibs-validate`](https://pypi.org/project/simplibs-validate/) and
73
+ that any custom type you define yourself is built on top of, too.
74
+
75
+ ```python
76
+ from simplibs.validate import validated_type
77
+ from simplibs.rules import greater_than
78
+
79
+ PositiveInt = validated_type(int, greater_than(0))
80
+ ```
81
+
82
+ This is deliberately *not* a new validation mechanism: `validated_type()` just builds
83
+ `Annotated[type_, *rules]`, and the actual checking still happens where it always did —
84
+ inside `simplibs-rules`' decomposition engine, invoked by `simplibs-validate`'s
85
+ `validate_call`/`validate_dataclass`. `simplibs-types` itself is purely a catalog of
86
+ named type definitions on top of both — it ships no validation logic and no
87
+ `validated_type()` implementation of its own; that lives in
88
+ [`simplibs-validate`](https://pypi.org/project/simplibs-validate/), which is why
89
+ `simplibs-types` now depends on it directly.
90
+
91
+ ---
92
+
93
+ ## 📦 Installation
94
+
95
+ ```bash
96
+ pip install simplibs-types
97
+ ```
98
+
99
+ `simplibs-rules` and [`simplibs-validate`](https://pypi.org/project/simplibs-validate/)
100
+ are both installed automatically as dependencies — `simplibs-validate` provides the
101
+ `validated_type()` builder that every type in this catalog is built on, and its
102
+ `validate_call`/`validate_dataclass` decorators are what actually enforces the types at
103
+ runtime.
104
+
105
+ ---
106
+
107
+ ## 🚀 Quick Start in 60 Seconds
108
+
109
+ ### Level 1: Use a ready-made type
110
+
111
+ ```python
112
+ from simplibs.types import int_positive
113
+ from simplibs.validate import validate_call
114
+
115
+ @validate_call
116
+ def set_quantity(amount: int_positive) -> None:
117
+ ...
118
+
119
+ set_quantity(3) # OK
120
+ set_quantity(-1) # raises ValidationError
121
+ ```
122
+
123
+ ### Level 2: Use a parameterized preset
124
+
125
+ Some types take arguments and return a fresh `Annotated` construct each time they're
126
+ called:
127
+
128
+ ```python
129
+ from simplibs.types import str_length_range
130
+
131
+ Username = str_length_range(3, 20)
132
+
133
+ @validate_call
134
+ def create_account(username: Username) -> None:
135
+ ...
136
+ ```
137
+
138
+ ### Level 3: Define your own named type
139
+
140
+ ```python
141
+ from simplibs.validate import validated_type
142
+ from simplibs.rules import is_string, contains
143
+
144
+ CompanyEmail = validated_type(str, is_string, contains("@simplibs.dev"))
145
+
146
+ @validate_call
147
+ def notify(email: CompanyEmail) -> None:
148
+ ...
149
+ ```
150
+
151
+ ---
152
+
153
+ ## 🧩 `validated_type` — the helper every type is built on
154
+
155
+ > `validated_type()` lives in [`simplibs-validate`](https://pypi.org/project/simplibs-validate/),
156
+ > not in this library. `simplibs-types` is installed on top of it — every preset in the
157
+ > catalog below is `validated_type()` under the hood, imported from `simplibs.validate`.
158
+
159
+ ```python
160
+ from simplibs.validate import validated_type
161
+
162
+
163
+ def validated_type(
164
+ type_: Any,
165
+ *rules: Rule | Callable[[Any], bool],
166
+ ) -> Any:
167
+ ...
168
+ ```
169
+
170
+ `validated_type()` is a thin, named wrapper around `Annotated[type_, *rules]`. It
171
+ performs no validation itself — it builds the annotation immediately and returns it;
172
+ actual decomposition happens later, whenever `build_typing_rule` (via `IsTyping`,
173
+ `validate_call`, or `validate_dataclass`) processes it. The only work it does up front
174
+ is fail fast: it requires at least one rule, and checks that every rule given is either
175
+ a `Rule` instance or a plain callable, naming the exact offending argument if not.
176
+
177
+ **Parameters**
178
+
179
+ * `type_` (*Any*) — the underlying type or typing construct (`int`, `list[int]`,
180
+ `int | None`, ...) — anything `build_typing_rule` already accepts.
181
+ * `*rules` (*Rule | Callable[[Any], bool]*) — one or more `Rule` instances or plain
182
+ callable predicates. At least one is required. Multiple rules may be given either as
183
+ separate positional arguments or pre-composed via `|`/`&`/`~` — both produce the same
184
+ final `Rule` once decomposed, and the two styles can be freely mixed:
185
+
186
+ ```python
187
+ PositiveInt = validated_type(int, greater_than(0))
188
+ PositiveInt = validated_type(int, is_integer, greater_than(0))
189
+ PositiveInt = validated_type(int, is_integer & greater_than(0))
190
+ ```
191
+
192
+ **Returns:** `Annotated[type_, *rules]` — an ordinary typing construct, usable directly
193
+ as a parameter, field, or variable annotation.
194
+
195
+ **Raises:** `ParamError` if no rules are given, or if any rule is neither a `Rule`
196
+ instance nor callable.
197
+
198
+ ---
199
+
200
+ ## 📖 Preset Catalog
201
+
202
+ Every preset below is a thin wrapper around `validated_type(type_, *rules)`, fully
203
+ documented on hover. Parameterless presets (`int_positive`, `dict_not_empty`, ...) are
204
+ ready-made `Annotated` constants; parameterized ones (`int_gt`, `str_length_range`, ...)
205
+ are factory functions that build a fresh `Annotated` construct per call.
206
+
207
+ ### 1. Collections
208
+
209
+ Validated types for `dict`, `list`, `set`, and `tuple` — non-emptiness, length
210
+ constraints, uniqueness, and per-item rules.
211
+
212
+ | Type | Description | Parameters |
213
+ |--------------------------|--------------------------------------------------|----------------------|
214
+ | `dict_not_empty` | Non-empty dictionary. | — |
215
+ | `dict_length` | Dictionary with an exact number of items. | `exact: int` |
216
+ | `dict_min_length` | Dictionary with a minimum number of items. | `min_length: int` |
217
+ | `dict_max_length` | Dictionary with a maximum number of items. | `max_length: int` |
218
+ | `list_not_empty` | Non-empty list. | — |
219
+ | `list_unique` | List with all unique items. | — |
220
+ | `list_unique_not_empty` | Non-empty list with all unique items. | — |
221
+ | `list_of` | List whose every item satisfies a given rule. | `item_rule` |
222
+ | `list_length` | List with an exact number of items. | `exact: int` |
223
+ | `list_min_length` | List with a minimum number of items. | `min_length: int` |
224
+ | `list_max_length` | List with a maximum number of items. | `max_length: int` |
225
+ | `set_not_empty` | Non-empty set. | — |
226
+ | `set_of` | Set whose every item satisfies a given rule. | `item_rule` |
227
+ | `set_length` | Set with an exact number of items. | `exact: int` |
228
+ | `set_min_length` | Set with a minimum number of items. | `min_length: int` |
229
+ | `set_max_length` | Set with a maximum number of items. | `max_length: int` |
230
+ | `tuple_not_empty` | Non-empty tuple. | — |
231
+ | `tuple_of` | Tuple whose every item satisfies a given rule. | `item_rule` |
232
+ | `tuple_length` | Tuple with an exact number of items. | `exact: int` |
233
+ | `tuple_min_length` | Tuple with a minimum number of items. | `min_length: int` |
234
+ | `tuple_max_length` | Tuple with a maximum number of items. | `max_length: int` |
235
+
236
+ ➡️ [Full reference (README_TYPES_COLLECTIONS)](https://github.com/simplibs/simplibs-types/blob/main/docs/README_TYPES_COLLECTIONS.md)
237
+
238
+ ### 2. Numeric
239
+
240
+ Validated types for `int`, `float`, and the `int | float` union (`number_*`) — sign,
241
+ zero, parity, ranges, and special float states (NaN, infinity).
242
+
243
+ | Type | Description | Parameters |
244
+ |----------------------------|------------------------------------------------------|-------------------------------------|
245
+ | `int_positive` | Positive integer. | — |
246
+ | `int_negative` | Negative integer. | — |
247
+ | `int_non_negative` | Non-negative integer. | — |
248
+ | `int_non_positive` | Non-positive integer. | — |
249
+ | `int_zero` | Integer equal to zero. | — |
250
+ | `int_not_zero` | Integer not equal to zero. | — |
251
+ | `int_even` | Even integer. | — |
252
+ | `int_odd` | Odd integer. | — |
253
+ | `int_positive_even` | Positive, even integer. | — |
254
+ | `int_positive_odd` | Positive, odd integer. | — |
255
+ | `int_non_negative_even` | Non-negative, even integer. | — |
256
+ | `int_uint8` | Integer in unsigned 8-bit range [0, 255]. | — |
257
+ | `int_int8` | Integer in signed 8-bit range [-128, 127]. | — |
258
+ | `int_percentage` | Integer percentage [0, 100]. | — |
259
+ | `int_port` | Integer network port [0, 65535]. | — |
260
+ | `int_year` | Integer calendar year [1, 9999]. | — |
261
+ | `int_month` | Integer calendar month [1, 12]. | — |
262
+ | `int_day_of_month` | Integer day of month [1, 31]. | — |
263
+ | `int_hour` | Integer hour, 24h clock [0, 23]. | — |
264
+ | `int_minute` | Integer minute [0, 59]. | — |
265
+ | `int_second` | Integer second [0, 59]. | — |
266
+ | `int_gt` / `int_ge` | Integer greater than / or equal to a threshold. | `threshold: int` |
267
+ | `int_lt` / `int_le` | Integer less than / or equal to a threshold. | `threshold: int` |
268
+ | `int_eq` / `int_ne` | Integer equal / not equal to a specific value. | `expected`/`forbidden: int` |
269
+ | `int_in_range` | Integer within an inclusive range. | `min_val: int, max_val: int` |
270
+ | `int_divisible_by` | Integer evenly divisible by a divisor. | `divisor: int` |
271
+ | `int_multiple_of` | Alias of `int_divisible_by`. | `divisor: int` |
272
+ | `float_positive` | Positive float. | — |
273
+ | `float_negative` | Negative float. | — |
274
+ | `float_non_negative` | Non-negative float. | — |
275
+ | `float_non_positive` | Non-positive float. | — |
276
+ | `float_zero` | Float equal to zero. | — |
277
+ | `float_not_zero` | Float not equal to zero. | — |
278
+ | `float_finite` | Finite float (not NaN, not infinite). | — |
279
+ | `float_not_nan` | Float that is not NaN. | — |
280
+ | `float_not_infinite` | Float that is not +/-infinity. | — |
281
+ | `float_probability` | Float in [0.0, 1.0]. | — |
282
+ | `float_percentage` | Float in [0.0, 100.0]. | — |
283
+ | `float_latitude` | Float in [-90.0, 90.0]. | — |
284
+ | `float_longitude` | Float in [-180.0, 180.0]. | — |
285
+ | `float_gt` / `float_ge` | Float greater than / or equal to a threshold. | `threshold: float` |
286
+ | `float_lt` / `float_le` | Float less than / or equal to a threshold. | `threshold: float` |
287
+ | `float_in_range` | Float within an inclusive range. | `min_val: float, max_val: float` |
288
+ | `number_positive` | Positive number (int or float). | — |
289
+ | `number_negative` | Negative number (int or float). | — |
290
+ | `number_non_negative` | Non-negative number (int or float). | — |
291
+ | `number_non_positive` | Non-positive number (int or float). | — |
292
+ | `number_zero` | Number equal to zero. | — |
293
+ | `number_not_zero` | Number not equal to zero. | — |
294
+ | `number_finite` | Finite number (int or float). | — |
295
+ | `number_in_range` | Number within an inclusive range. | `min_val, max_val: Any` |
296
+
297
+ ➡️ [Full reference — integers (README_TYPES_INT)](https://github.com/simplibs/simplibs-types/blob/main/docs/README_TYPES_INT.md)
298
+ ➡️ [Full reference — floats & numbers (README_TYPES_FLOAT)](https://github.com/simplibs/simplibs-types/blob/main/docs/README_TYPES_FLOAT.md)
299
+
300
+ ### 3. Boolean
301
+
302
+ | Type | Description | Parameters |
303
+ |---------------|--------------------------------|------------|
304
+ | `bool_true` | Boolean that must be `True`. | — |
305
+ | `bool_false` | Boolean that must be `False`.| — |
306
+
307
+ ➡️ [Full reference (README_TYPES_BOOL)](https://github.com/simplibs/simplibs-types/blob/main/docs/README_TYPES_BOOL.md)
308
+
309
+ ### 4. String
310
+
311
+ Validated types for `str` — emptiness/blankness, character classes, casing, patterns,
312
+ length, and value restriction.
313
+
314
+ | Type | Description | Parameters |
315
+ |-----------------------|---------------------------------------------------------|----------------------------------------|
316
+ | `str_empty` | Empty string. | — |
317
+ | `str_not_empty` | Non-empty string. | — |
318
+ | `str_blank` | Empty or whitespace-only string. | — |
319
+ | `str_not_blank` | String with at least one non-whitespace character. | — |
320
+ | `str_whitespace` | String consisting entirely of whitespace. | — |
321
+ | `str_alpha` | String consisting entirely of letters. | — |
322
+ | `str_alnum` | String consisting entirely of letters and/or digits. | — |
323
+ | `str_digit` | String consisting entirely of digits. | — |
324
+ | `str_ascii` | String consisting entirely of ASCII characters. | — |
325
+ | `str_printable` | String consisting entirely of printable characters. | — |
326
+ | `str_lower` | Entirely lowercase string. | — |
327
+ | `str_upper` | Entirely uppercase string. | — |
328
+ | `str_title` | Title-case string. | — |
329
+ | `str_no_whitespace` | String with no whitespace characters at all. | — |
330
+ | `str_single_line` | String with no line breaks. | — |
331
+ | `str_identifier` | String that is a valid Python identifier. | — |
332
+ | `str_slug` | URL-friendly slug string. | — |
333
+ | `str_snake_case` | snake_case string. | — |
334
+ | `str_email` | String matching a basic email address shape. | — |
335
+ | `str_url` | String matching a basic HTTP(S) URL shape. | — |
336
+ | `str_uuid` | String in canonical UUID format. | — |
337
+ | `str_hex_color` | String in 6-digit hex color format. | — |
338
+ | `str_length` | String with an exact length. | `exact: int` |
339
+ | `str_min_length` | String with a minimum length. | `min_length: int` |
340
+ | `str_max_length` | String with a maximum length. | `max_length: int` |
341
+ | `str_length_range` | String with a length in an inclusive range. | `min_length: int, max_length: int` |
342
+ | `str_starts_with` | String starting with a given prefix. | `prefix: str` |
343
+ | `str_ends_with` | String ending with a given suffix. | `suffix: str` |
344
+ | `str_contains` | String containing a given substring. | `substring: str` |
345
+ | `str_matches` | String fully matching a regex pattern. | `pattern: str` |
346
+ | `str_one_of` | String restricted to a fixed set of allowed values. | `*options: str` |
347
+
348
+ ➡️ [Full reference (README_TYPES_STRING)](https://github.com/simplibs/simplibs-types/blob/main/docs/README_TYPES_STRING.md)
349
+
350
+ ### 5. Bytes
351
+
352
+ | Type | Description | Parameters |
353
+ |------------------------|-----------------------------------------------|--------------------------------------|
354
+ | `bytes_empty` | Empty bytes. | — |
355
+ | `bytes_not_empty` | Non-empty bytes. | — |
356
+ | `bytes_length` | Bytes with an exact length. | `exact: int` |
357
+ | `bytes_min_length` | Bytes with a minimum length. | `min_length: int` |
358
+ | `bytes_max_length` | Bytes with a maximum length. | `max_length: int` |
359
+ | `bytes_length_range` | Bytes with a length in an inclusive range. | `min_length: int, max_length: int` |
360
+
361
+ ➡️ [Full reference (README_TYPES_BYTES)](https://github.com/simplibs/simplibs-types/blob/main/docs/README_TYPES_BYTES.md)
362
+
363
+ ---
364
+
365
+ ## 💡 Why every type has a docstring
366
+
367
+ Every preset — parameterless constant or parameterized factory alike — carries a
368
+ docstring describing what it validates, its parameters (if any), and a usage example.
369
+ That's a deliberate design choice: since `Annotated[type_, *rules]` doesn't surface its
370
+ constraints in a hover tooltip on its own, the docstring is what makes `int_uint8` or
371
+ `str_email` self-explanatory at the call site, without needing to open documentation or
372
+ jump to the definition.
373
+
374
+ ---
375
+
376
+ ## 🔗 Related libraries
377
+
378
+ * **[`simplibs-rules`](https://pypi.org/project/simplibs-rules/)** — the `Rule` base
379
+ class and every predicate (`is_integer`, `greater_than`, `contains`, ...) that
380
+ presets here are composed from.
381
+ * **[`simplibs-validate`](https://pypi.org/project/simplibs-validate/)** — hosts
382
+ `validated_type()` itself, plus `validate()`, `validate_call`, and
383
+ `validate_dataclass`, which is how types from this library actually get enforced.
384
+ `simplibs-types` depends directly on it.
385
+
386
+ ---
387
+
388
+ ## ☯️ About simplibs
389
+
390
+ All libraries in the **simplibs** (Simple Libraries) ecosystem share a common
391
+ engineering philosophy:
392
+
393
+ * **Dyslexia-friendly:**
394
+ We actively minimize cognitive load. Code is atomized into small, self-contained units,
395
+ files are named directly after the logical task they perform, and explanations describe
396
+ *why* something is designed, not just *what* it is.
397
+ * **Programmer's Zen:**
398
+ Nothing should be missing, and nothing should be superfluous. We value clean execution
399
+ paths and robust, understandable code architectures over rushed, messy feature sets.
400
+ * **Defensive Style:**
401
+ We actively anticipate edge cases and failure modes so that only safe operational paths
402
+ remain. Our code is built to degrade gracefully rather than crash unexpectedly.
403
+ * **Minimalism:**
404
+ Find the most direct path to the goal in as few operational steps as possible without
405
+ taking shortcuts on safety, readability, or completeness.
406
+ * **Code as Craft:**
407
+ Code should be pleasant to look at, readable at a glance, and evoke structural harmony.
408
+ We treat software engineering as a precision trade.
409
+
410
+ ---
411
+
412
+ ### 🤝 Contributing & Community
413
+
414
+ This is an **open-source project** built with love and care. We strongly believe in
415
+ community collaboration and welcome any feedback, bug reports, or feature ideas!
416
+
417
+ * **Want to contribute?** Feel free to open an Issue or submit a Pull Request.
418
+ * **Want to get in touch?** If you'd like to discuss the project further, collaborate,
419
+ or just say hello, feel free to open a GitHub Issue or start a Discussion.
420
+
421
+ ---
422
+
423
+ ### 📝 License
424
+
425
+ This library is released under the **MIT License**. Build great things!
426
+
427
+ ---
428
+
429
+ [▲ Back to Top](#-simplibs-types)