Coverage for src / questions / validators / min_value.py: 100%
9 statements
« prev ^ index » next coverage.py v7.12.0, created at 2025-11-21 16:36 +0000
« prev ^ index » next coverage.py v7.12.0, created at 2025-11-21 16:36 +0000
1from prompt_toolkit.validation import ValidationError
4def validate(value, schema):
5 """
6 Return { value to use, stop (True/False) }
8 If stop is True, the rest of the validators are skipped.
9 """
10 vartype = schema.get("type", "integer")
11 if vartype != "integer":
12 return value, False
14 min_value = schema.get("min_value", None)
15 if min_value and int(value) < min_value:
16 raise ValidationError(message=f"Answer cannot be less than {min_value}") from None
17 return value, False