11 lines
312 B
Python
11 lines
312 B
Python
|
from wtforms.validators import ValidationError
|
||
|
|
||
|
def value(min=0, max=None):
|
||
|
message = f'Value must be between {min} and {max}.'
|
||
|
|
||
|
def _length(form, field):
|
||
|
value = field.data or 0
|
||
|
if value < min or max != None and value > max:
|
||
|
raise ValidationError(message)
|
||
|
|
||
|
return _length
|