Hi Alexey,
I'm not sure I understand why the approach Aymeric suggested is not viable for
your use case.
It can be implemented in a few lines and doesn't require any modification to
Django core.
class ShortCircuitValidator(object):
def __init__(self, *validators):
self.validators = validators
def __call__(self, value):
for validator in self.validators:
validator(value)
class FileForm(forms.Form):
file = forms.FileField(
validators=[ShortCircuitValidator(
FileSizeValidator(max_size='500 kb'),
FileTypeValidator(extensions=['xlsx']),
)],
)
Simon