validate_as_int
Validates that a given value can be interpreted as an integer and returns the integer representation, or raises a ValueError if the conversion fails.
def validate_as_int(
value: Any,
min_value: int = None,
max_value: int = None
) - > int
Validates that a given value can be interpreted as an integer and falls within an optional inclusive range.
Parameters
| Name | Type | Description |
|---|---|---|
| value | Any | The input value to be validated and converted into an integer. |
| min_value | int = None | The minimum allowable value for the integer; validation fails if the value is less than this. |
| max_value | int = None | The maximum allowable value for the integer; validation fails if the value is greater than this. |
Returns
| Type | Description |
|---|---|
int | The validated integer value if all checks pass. |