Skip to content

Commit eae7d94

Browse files
committed
docs: say between, length and domain return ValidationError for bad arguments
The Raises sections of between(), length() and domain() name ValueError, TypeError and UnicodeError, but the validator decorator turns those into a ValidationError, so an except clause for them never runs. List these cases as ValidationError entries under Returns and drop the Raises sections. No code changes.
1 parent 22786cc commit eae7d94

3 files changed

Lines changed: 3 additions & 10 deletions

File tree

‎src/validators/between.py‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ def between(
5353
Returns:
5454
(Literal[True]): If `value` is in between the given conditions.
5555
(ValidationError): If `value` is not in between the given conditions.
56-
57-
Raises:
58-
(ValueError): If `min_val` is greater than `max_val`.
59-
(TypeError): If there's a type mismatch during comparison.
56+
(ValidationError): If `min_val` is greater than `max_val` or the values cannot be compared.
6057
6158
Note:
6259
- `PossibleValueTypes` = `TypeVar("PossibleValueTypes", int, float, str, datetime, None)`

‎src/validators/domain.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ def domain(
8787
Returns:
8888
(Literal[True]): If `value` is a valid domain name.
8989
(ValidationError): If `value` is an invalid domain name.
90-
91-
Raises:
92-
(UnicodeError): If `value` cannot be encoded into `idna` or decoded into `utf-8`.
90+
(ValidationError): If `value` cannot be encoded into `idna` or decoded into `utf-8`.
9391
"""
9492
if not value:
9593
return False

‎src/validators/length.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ def length(value: str, /, *, min_val: Union[int, None] = None, max_val: Union[in
3333
Returns:
3434
(Literal[True]): If `len(value)` is in between the given conditions.
3535
(ValidationError): If `len(value)` is not in between the given conditions.
36-
37-
Raises:
38-
(ValueError): If either `min_val` or `max_val` is negative.
36+
(ValidationError): If either `min_val` or `max_val` is negative.
3937
"""
4038
if min_val is not None and min_val < 0:
4139
raise ValueError("Length cannot be negative. `min_val` is less than zero.")

0 commit comments

Comments
 (0)