14 lines
440 B
Python
14 lines
440 B
Python
from validator import ValidationError
|
|
|
|
|
|
def validate_lenth(value: str, max_length: int, min_length: int = 4):
|
|
length = len(value)
|
|
if length > max_length:
|
|
raise ValidationError(
|
|
"Length is {}. It is longer than {}".format(length, max_length)
|
|
)
|
|
elif length < min_length:
|
|
raise ValidationError(
|
|
"Length is {}. It is shorter than {}".format(length, min_length)
|
|
)
|