minimindslab-uuid-validate 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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MiniMindsLab
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,44 @@
1
+ Metadata-Version: 2.4
2
+ Name: minimindslab-uuid-validate
3
+ Version: 0.1.0
4
+ Summary: Validate, classify, and normalize UUID strings offline with strict deterministic parsing for common UUID forms.
5
+ Author: MiniMindsLab
6
+ License: MIT
7
+ Requires-Python: >=3.11
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Dynamic: license-file
11
+
12
+ # MiniMindsLab UUID Validate
13
+
14
+ Tiny stdlib-only UUID validation helpers for Python.
15
+
16
+ ## Features
17
+
18
+ - Strict parser for canonical UUID text form (`8-4-4-4-12` hex)
19
+ - Normalization to lowercase canonical output
20
+ - UUID version extraction
21
+ - Safe boolean validator
22
+
23
+ ## Public API
24
+
25
+ - `parse_uuid(value: str) -> str`
26
+ - `uuid_version(value: object) -> int | None`
27
+ - `is_uuid(value: object) -> bool`
28
+
29
+ ## Example
30
+
31
+ ```python
32
+ from minimindslab_uuid_validate import parse_uuid, uuid_version, is_uuid
33
+
34
+ u = parse_uuid("550E8400-E29B-41D4-A716-446655440000")
35
+ assert u == "550e8400-e29b-41d4-a716-446655440000"
36
+ assert uuid_version(u) == 4
37
+ assert is_uuid(u) is True
38
+ assert is_uuid("not-a-uuid") is False
39
+ ```
40
+
41
+ ## Guarantees
42
+
43
+ - Pure Python, standard library only
44
+ - No network calls, subprocesses, or dynamic code execution
@@ -0,0 +1,33 @@
1
+ # MiniMindsLab UUID Validate
2
+
3
+ Tiny stdlib-only UUID validation helpers for Python.
4
+
5
+ ## Features
6
+
7
+ - Strict parser for canonical UUID text form (`8-4-4-4-12` hex)
8
+ - Normalization to lowercase canonical output
9
+ - UUID version extraction
10
+ - Safe boolean validator
11
+
12
+ ## Public API
13
+
14
+ - `parse_uuid(value: str) -> str`
15
+ - `uuid_version(value: object) -> int | None`
16
+ - `is_uuid(value: object) -> bool`
17
+
18
+ ## Example
19
+
20
+ ```python
21
+ from minimindslab_uuid_validate import parse_uuid, uuid_version, is_uuid
22
+
23
+ u = parse_uuid("550E8400-E29B-41D4-A716-446655440000")
24
+ assert u == "550e8400-e29b-41d4-a716-446655440000"
25
+ assert uuid_version(u) == 4
26
+ assert is_uuid(u) is True
27
+ assert is_uuid("not-a-uuid") is False
28
+ ```
29
+
30
+ ## Guarantees
31
+
32
+ - Pure Python, standard library only
33
+ - No network calls, subprocesses, or dynamic code execution
@@ -0,0 +1,19 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77.0.3"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "minimindslab-uuid-validate"
7
+ version = "0.1.0"
8
+ description = "Validate, classify, and normalize UUID strings offline with strict deterministic parsing for common UUID forms."
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "MiniMindsLab" }]
13
+ dependencies = []
14
+
15
+ [tool.setuptools]
16
+ package-dir = {"" = "src"}
17
+
18
+ [tool.setuptools.packages.find]
19
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,62 @@
1
+ """MiniMindsLab UUID Validate.
2
+
3
+ Strict deterministic UUID string validation and normalization.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ import re
9
+ from typing import Final
10
+
11
+ __all__ = ["parse_uuid", "uuid_version", "is_uuid"]
12
+
13
+ _UUID_PATTERN: Final[re.Pattern[str]] = re.compile(
14
+ r"^[0-9A-Fa-f]{8}-"
15
+ r"[0-9A-Fa-f]{4}-"
16
+ r"[0-9A-Fa-f]{4}-"
17
+ r"[0-9A-Fa-f]{4}-"
18
+ r"[0-9A-Fa-f]{12}$"
19
+ )
20
+
21
+
22
+ def parse_uuid(value: str) -> str:
23
+ """Validate and normalize a UUID string.
24
+
25
+ Accepts only canonical 8-4-4-4-12 hexadecimal form with hyphens.
26
+ Returns lowercase canonical form.
27
+
28
+ Raises:
29
+ TypeError: if value is not a string.
30
+ ValueError: if value is not a valid canonical UUID string.
31
+ """
32
+ if not isinstance(value, str):
33
+ raise TypeError("value must be a string")
34
+ if not _UUID_PATTERN.fullmatch(value):
35
+ raise ValueError("value is not a valid canonical UUID string")
36
+ return value.lower()
37
+
38
+
39
+ def uuid_version(value: object) -> int | None:
40
+ """Return UUID version (1-5) for valid UUID strings, else None."""
41
+ if not isinstance(value, str):
42
+ return None
43
+ try:
44
+ normalized = parse_uuid(value)
45
+ except (TypeError, ValueError):
46
+ return None
47
+ version_char = normalized[14]
48
+ version = int(version_char, 16)
49
+ if 1 <= version <= 5:
50
+ return version
51
+ return None
52
+
53
+
54
+ def is_uuid(value: object) -> bool:
55
+ """Return True if value is a valid canonical UUID string."""
56
+ if not isinstance(value, str):
57
+ return False
58
+ try:
59
+ parse_uuid(value)
60
+ except (TypeError, ValueError):
61
+ return False
62
+ return True
@@ -0,0 +1,44 @@
1
+ Metadata-Version: 2.4
2
+ Name: minimindslab-uuid-validate
3
+ Version: 0.1.0
4
+ Summary: Validate, classify, and normalize UUID strings offline with strict deterministic parsing for common UUID forms.
5
+ Author: MiniMindsLab
6
+ License: MIT
7
+ Requires-Python: >=3.11
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Dynamic: license-file
11
+
12
+ # MiniMindsLab UUID Validate
13
+
14
+ Tiny stdlib-only UUID validation helpers for Python.
15
+
16
+ ## Features
17
+
18
+ - Strict parser for canonical UUID text form (`8-4-4-4-12` hex)
19
+ - Normalization to lowercase canonical output
20
+ - UUID version extraction
21
+ - Safe boolean validator
22
+
23
+ ## Public API
24
+
25
+ - `parse_uuid(value: str) -> str`
26
+ - `uuid_version(value: object) -> int | None`
27
+ - `is_uuid(value: object) -> bool`
28
+
29
+ ## Example
30
+
31
+ ```python
32
+ from minimindslab_uuid_validate import parse_uuid, uuid_version, is_uuid
33
+
34
+ u = parse_uuid("550E8400-E29B-41D4-A716-446655440000")
35
+ assert u == "550e8400-e29b-41d4-a716-446655440000"
36
+ assert uuid_version(u) == 4
37
+ assert is_uuid(u) is True
38
+ assert is_uuid("not-a-uuid") is False
39
+ ```
40
+
41
+ ## Guarantees
42
+
43
+ - Pure Python, standard library only
44
+ - No network calls, subprocesses, or dynamic code execution
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/minimindslab_uuid_validate/__init__.py
5
+ src/minimindslab_uuid_validate.egg-info/PKG-INFO
6
+ src/minimindslab_uuid_validate.egg-info/SOURCES.txt
7
+ src/minimindslab_uuid_validate.egg-info/dependency_links.txt
8
+ src/minimindslab_uuid_validate.egg-info/top_level.txt
9
+ tests/test_uuid_validate.py
@@ -0,0 +1,50 @@
1
+ import unittest
2
+
3
+ from minimindslab_uuid_validate import is_uuid, parse_uuid, uuid_version
4
+
5
+
6
+ class TestUUIDValidate(unittest.TestCase):
7
+ def test_parse_uuid_accepts_canonical_and_normalizes(self):
8
+ upper = "550E8400-E29B-41D4-A716-446655440000"
9
+ lower = "550e8400-e29b-41d4-a716-446655440000"
10
+ self.assertEqual(parse_uuid(upper), lower)
11
+ self.assertEqual(parse_uuid(lower), lower)
12
+
13
+ def test_parse_uuid_rejects_malformed_inputs(self):
14
+ invalid_values = [
15
+ "",
16
+ "550e8400e29b41d4a716446655440000", # missing hyphens
17
+ "550e8400-e29b-41d4-a716-44665544000", # short
18
+ "550e8400-e29b-41d4-a716-4466554400000", # long
19
+ "550e8400-e29b-41d4-a716-44665544zzzz", # non-hex
20
+ "550e8400-e29b-41d4-a716_446655440000", # wrong separator
21
+ ]
22
+ for value in invalid_values:
23
+ with self.assertRaises(ValueError):
24
+ parse_uuid(value)
25
+
26
+ def test_parse_uuid_rejects_non_string(self):
27
+ for value in (None, 123, 1.5, [], {}, True):
28
+ with self.assertRaises(TypeError):
29
+ parse_uuid(value) # type: ignore[arg-type]
30
+
31
+ def test_uuid_version_valid_and_invalid(self):
32
+ self.assertEqual(uuid_version("f47ac10b-58cc-0372-8567-0e02b2c3d479"), None) # v0 unsupported
33
+ self.assertEqual(uuid_version("6ba7b810-9dad-11d1-80b4-00c04fd430c8"), 1)
34
+ self.assertEqual(uuid_version("6ba7b811-9dad-21d1-80b4-00c04fd430c8"), 2)
35
+ self.assertEqual(uuid_version("6ba7b812-9dad-31d1-80b4-00c04fd430c8"), 3)
36
+ self.assertEqual(uuid_version("550e8400-e29b-41d4-a716-446655440000"), 4)
37
+ self.assertEqual(uuid_version("6ba7b814-9dad-51d1-80b4-00c04fd430c8"), 5)
38
+ self.assertIsNone(uuid_version("not-a-uuid"))
39
+ self.assertIsNone(uuid_version(None))
40
+
41
+ def test_is_uuid_behavior(self):
42
+ self.assertTrue(is_uuid("550e8400-e29b-41d4-a716-446655440000"))
43
+ self.assertTrue(is_uuid("550E8400-E29B-41D4-A716-446655440000"))
44
+ self.assertFalse(is_uuid("550e8400e29b41d4a716446655440000"))
45
+ self.assertFalse(is_uuid("not-a-uuid"))
46
+ self.assertFalse(is_uuid(None))
47
+
48
+
49
+ if __name__ == "__main__":
50
+ unittest.main()