IsIntegerInRange🔗

Type: Transpilable verification function
Check that the integer text is within the given range.
The text is expected to consist of decimal digits with an optional sign.
text🔗
Text to be checked
max_negative🔗
Largest allowed magnitude of a negative number
max_positive🔗
Largest allowed positive number
Return🔗
True if the text is within the range

Code

digits = text.lstrip("+-").lstrip("0")

if text[:1] == "-":
    return _is_magnitude_at_most(digits, max_negative)

return _is_magnitude_at_most(digits, max_positive)