From eae7d941718246b3dae9b3b2f4e61e42165a8e09 Mon Sep 17 00:00:00 2001 From: spicysharkco <321699413+spicysharkco@users.noreply.github.com> Date: Sun, 25 Oct 2026 21:24:28 +0000 Subject: [PATCH] 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. --- src/validators/between.py | 5 +---- src/validators/domain.py | 4 +--- src/validators/length.py | 4 +--- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/validators/between.py b/src/validators/between.py index b37f164c..108c9578 100644 --- a/src/validators/between.py +++ b/src/validators/between.py @@ -53,10 +53,7 @@ def between( Returns: (Literal[True]): If `value` is in between the given conditions. (ValidationError): If `value` is not in between the given conditions. - - Raises: - (ValueError): If `min_val` is greater than `max_val`. - (TypeError): If there's a type mismatch during comparison. + (ValidationError): If `min_val` is greater than `max_val` or the values cannot be compared. Note: - `PossibleValueTypes` = `TypeVar("PossibleValueTypes", int, float, str, datetime, None)` diff --git a/src/validators/domain.py b/src/validators/domain.py index ee6db4e7..55847fe7 100644 --- a/src/validators/domain.py +++ b/src/validators/domain.py @@ -87,9 +87,7 @@ def domain( Returns: (Literal[True]): If `value` is a valid domain name. (ValidationError): If `value` is an invalid domain name. - - Raises: - (UnicodeError): If `value` cannot be encoded into `idna` or decoded into `utf-8`. + (ValidationError): If `value` cannot be encoded into `idna` or decoded into `utf-8`. """ if not value: return False diff --git a/src/validators/length.py b/src/validators/length.py index e49091d4..f8057b86 100644 --- a/src/validators/length.py +++ b/src/validators/length.py @@ -33,9 +33,7 @@ def length(value: str, /, *, min_val: Union[int, None] = None, max_val: Union[in Returns: (Literal[True]): If `len(value)` is in between the given conditions. (ValidationError): If `len(value)` is not in between the given conditions. - - Raises: - (ValueError): If either `min_val` or `max_val` is negative. + (ValidationError): If either `min_val` or `max_val` is negative. """ if min_val is not None and min_val < 0: raise ValueError("Length cannot be negative. `min_val` is less than zero.")