django / django/new-features

max_size and min_size validation for `forms.fields.FileField`

Open
#89 5 comments 14 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
188
Forks
7
PR merge metrics
No merged PRs in 30d

Description

### Code of Conduct

- [x] I agree to follow Django's Code of Conduct

### Feature Description

hi
adding validation for max size and min size of files

### Problem

since files can be uploaded by users, having some validation on them could become necessary for developers

### Request or proposal

proposal

### Additional Details

this was discussed in https://forum.djangoproject.com/t/proposal-max-and-min-size-validation-for-filefield/43232 and https://code.djangoproject.com/ticket/36685

we already get size of the file in the `to_python` method in form field and check for empty files
might just turn it into checking both side of size

### Implementation Suggestions

this could be either a validator function that will be added to list of validators
or a parameter to `FileField` itself, which could be validated in the `validate` method

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.