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

Le lundi 26 septembre 2016 07:05:36 UTC-4, Alexey Rogachev a écrit :
>
> I opened ticket https://code.djangoproject.com/ticket/27263.
>
> Do you think the solution I suggested in comment is OK?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/5895bcc4-1289-4adf-80a3-f595806d49a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to