X7ROOT File Manager
Current Path:
/opt/alt/python311/lib/python3.11/site-packages/validators
opt
/
alt
/
python311
/
lib
/
python3.11
/
site-packages
/
validators
/
📁
..
📄
__init__.py
(1.86 KB)
📁
__pycache__
📄
_extremes.py
(1.01 KB)
📄
_tld.txt
(9.4 KB)
📄
between.py
(2.39 KB)
📄
btc_address.py
(1.62 KB)
📄
card.py
(5.63 KB)
📄
country.py
(14.57 KB)
📄
cron.py
(2.23 KB)
📄
domain.py
(2.4 KB)
📄
email.py
(2.72 KB)
📄
encoding.py
(1.34 KB)
📄
finance.py
(3.22 KB)
📄
hashes.py
(3.21 KB)
📄
hostname.py
(4.05 KB)
📁
i18n
📄
iban.py
(1.05 KB)
📄
ip_address.py
(4.34 KB)
📄
length.py
(1.45 KB)
📄
mac_address.py
(865 B)
📄
py.typed
(0 B)
📄
slug.py
(750 B)
📄
uri.py
(1.78 KB)
📄
url.py
(7.23 KB)
📄
utils.py
(3.1 KB)
📄
uuid.py
(1.04 KB)
Editing: length.py
"""Length.""" # standard from typing import Union # local from .between import between from .utils import validator @validator def length(value: str, /, *, min_val: Union[int, None] = None, max_val: Union[int, None] = None): """Return whether or not the length of given string is within a specified range. Examples: >>> length('something', min_val=2) # Output: True >>> length('something', min_val=9, max_val=9) # Output: True >>> length('something', max_val=5) # Output: ValidationError(func=length, ...) Args: value: The string to validate. min_val: The minimum required length of the string. If not provided, minimum length will not be checked. max_val: The maximum length of the string. If not provided, maximum length will not be checked. 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. """ if min_val is not None and min_val < 0: raise ValueError("Length cannot be negative. `min_val` is less than zero.") if max_val is not None and max_val < 0: raise ValueError("Length cannot be negative. `max_val` is less than zero.") return bool(between(len(value), min_val=min_val, max_val=max_val))
Upload File
Create Folder