Validator
Validators
are used to validate the data after filters have been applied.
They ensure that the input data meets the required conditions before further processing.
Overview
Validators can be added into the add
method for a specific field or as a global validator for all fields in add_global_validator
.
The global validation will be executed before the specific field validation.
Example
from flask_inputfilter import InputFilter
from flask_inputfilter.validators import IsIntegerValidator, RangeValidator
class UpdatePointsInputFilter(InputFilter):
def __init__(self):
super().__init__()
self.add(
'id',
required=True
)
self.add(
'points',
required=True,
validators=[RangeValidator(min_value=0, max_value=10)]
)
self.add_global_validator(IsIntegerValidator())
Available Validators
Special Validators
Following are the special validators that are used to combine or mutate the normal validators: