Number validator
Input
validate = make_validator(min_value=0, max_value=10, allowed_types=(int, float)) validate(5)
Output
(True, [])
5 is numeric, within the configured range, and of an allowed type.
Full lesson preview
Build a configurable validator factory that returns a function which validates values against configured rules.
Problem statement
Task
Examples
Input
validate = make_validator(min_value=0, max_value=10, allowed_types=(int, float)) validate(5)
Output
(True, [])
5 is numeric, within the configured range, and of an allowed type.
Input format
Output format
Constraints
Samples
Input
make_validator(min_value=0, max_value=10)(5)
Output
(True, [])
5 is within range