enforce-rules 3.2.7__tar.gz → 3.2.9__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: enforce-rules
3
- Version: 3.2.7
3
+ Version: 3.2.9
4
4
  Summary: Runtime rule validation for Python using dictionary-based constraints.
5
5
  Author: Jake Loepker, Microsoft Copilot (AI Assistant)
6
6
  License: BSD 3-Clause License
@@ -63,7 +63,7 @@ MAJOR: 3
63
63
 
64
64
  MINOR: 2
65
65
 
66
- PATCH: 7
66
+ PATCH: 9
67
67
 
68
68
  If you need to catch up, you can see the full version history in the [CHANGELOG](https://github.com/Loepker-James/enforce-rules/blob/main/CHANGELOG.md).
69
69
 
@@ -7,7 +7,7 @@ MAJOR: 3
7
7
 
8
8
  MINOR: 2
9
9
 
10
- PATCH: 7
10
+ PATCH: 9
11
11
 
12
12
  If you need to catch up, you can see the full version history in the [CHANGELOG](https://github.com/Loepker-James/enforce-rules/blob/main/CHANGELOG.md).
13
13
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "enforce-rules"
3
- version = "3.2.7"
3
+ version = "3.2.9"
4
4
  description = "Runtime rule validation for Python using dictionary-based constraints."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -3,23 +3,25 @@ from collections.abc import Iterable, Sequence, Container
3
3
  import re
4
4
  from datetime import datetime
5
5
  from chess import Piece
6
+ from pydantic import PositiveInt
6
7
 
7
8
  Number: TypeAlias = int | float
9
+ LengthType: TypeAlias = PositiveInt | Literal[0]
8
10
  # -----------------------------
9
11
  # VALIDATOR FUNCTIONS (DEFINED FIRST)
10
12
  # -----------------------------
11
13
 
12
- def _validate_length(value: Sequence, expected: int) -> None:
14
+ def _validate_length(value: Sequence, expected: LengthType) -> None:
13
15
  if len(value) != expected:
14
16
  raise ValueError(f"Expected length {expected}, got {len(value)}")
15
17
 
16
18
 
17
- def _validate_min_length(value: Sequence, expected: int) -> None:
19
+ def _validate_min_length(value: Sequence, expected: LengthType) -> None:
18
20
  if len(value) < expected:
19
21
  raise ValueError(f"Expected min length {expected}, got {len(value)}")
20
22
 
21
23
 
22
- def _validate_max_length(value: Sequence, expected: int) -> None:
24
+ def _validate_max_length(value: Sequence, expected: LengthType) -> None:
23
25
  if len(value) > expected:
24
26
  raise ValueError(f"Expected max length {expected}, got {len(value)}")
25
27
 
@@ -266,7 +268,7 @@ def validate(value: T, rules: ValidateDict) -> T:
266
268
 
267
269
  return value
268
270
 
269
- def is_valid(value: object, rules: ValidateDict) -> bool:
271
+ def is_valid(value: T, rules: ValidateDict) -> bool:
270
272
  try:
271
273
  validate(value, rules)
272
274
  return True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: enforce-rules
3
- Version: 3.2.7
3
+ Version: 3.2.9
4
4
  Summary: Runtime rule validation for Python using dictionary-based constraints.
5
5
  Author: Jake Loepker, Microsoft Copilot (AI Assistant)
6
6
  License: BSD 3-Clause License
@@ -63,7 +63,7 @@ MAJOR: 3
63
63
 
64
64
  MINOR: 2
65
65
 
66
- PATCH: 7
66
+ PATCH: 9
67
67
 
68
68
  If you need to catch up, you can see the full version history in the [CHANGELOG](https://github.com/Loepker-James/enforce-rules/blob/main/CHANGELOG.md).
69
69
 
File without changes
File without changes