init
This commit is contained in:
13
spider/normalutils/utils/validation.py
Normal file
13
spider/normalutils/utils/validation.py
Normal file
@ -0,0 +1,13 @@
|
||||
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)
|
||||
)
|
Reference in New Issue
Block a user