Skip to content

Commit 7e90089

Browse files
Use relative imports and document BoolValidator
Convert absolute imports to relative in validator modules to avoid package import issues. Add BoolValidator usage/docs and include a combined pytest command to run validator-focused tests.
1 parent 17c3ecc commit 7e90089

5 files changed

Lines changed: 25 additions & 5 deletions

File tree

ilovepdf/validators/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,21 @@ IntValidator.validate_options(90, {0, 90, 180, 270}, "rotation") # OK
6464
IntValidator.validate_options(45, {0, 90, 180, 270}, "rotation") # Raises IntNotInAllowedSetError
6565
```
6666

67+
### BoolValidator
68+
69+
Validates that a value is strictly a boolean (`True` or `False`).
70+
71+
**Methods:**
72+
- `validate(value, param_name)` - Ensure the value is a boolean; raises a `TypeError` if not.
73+
74+
**Example:**
75+
```python
76+
from ilovepdf.validators import BoolValidator
77+
78+
BoolValidator.validate(True, "flatten") # OK
79+
BoolValidator.validate("true", "flatten") # Raises TypeError
80+
```
81+
6782
### FloatValidator
6883

6984
Validates float values with various constraints.
@@ -231,6 +246,11 @@ pytest tests/unit/test_bool_validator.py -v
231246
pytest tests/unit/test_choice_validator.py -v
232247
```
233248

249+
To execute the validator-focused suite (including `BoolValidator`) in a single command:
250+
```bash
251+
pytest tests/unit/test_string_validator.py tests/unit/test_int_validator.py tests/unit/test_bool_validator.py tests/unit/test_choice_validator.py -v
252+
```
253+
234254
## See Also
235255

236256
- `ilovepdf/abstract_task_element.py` - AbstractTaskElement base class

ilovepdf/validators/bool_validator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Provides the BoolValidator class to validate boolean inputs for tasks and models.
44
"""
55

6-
from ilovepdf.exceptions import InvalidChoiceError
6+
from ..exceptions import InvalidChoiceError
77

88

99
class BoolValidator:

ilovepdf/validators/choice_validator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from collections.abc import Iterable
88
from typing import Any
99

10-
from ilovepdf.exceptions import InvalidChoiceError
10+
from ..exceptions import InvalidChoiceError
1111

1212

1313
class ChoiceValidator:

ilovepdf/validators/float_validator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from typing import Any
88

9-
from ilovepdf.exceptions import FloatOutOfRangeError, InvalidChoiceError
9+
from ..exceptions import FloatOutOfRangeError, InvalidChoiceError
1010

1111

1212
class FloatValidator:

ilovepdf/validators/int_validator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
from typing import Any
88

9-
from ilovepdf.exceptions import (
9+
from ..exceptions import (
1010
IntNotInAllowedSetError,
1111
IntOutOfRangeError,
1212
NotAnIntError,
1313
)
14-
from ilovepdf.validators.choice_validator import ChoiceValidator
14+
from . import ChoiceValidator
1515

1616

1717
class IntValidator:

0 commit comments

Comments
 (0)