This repository has been archived on 2022-03-12. You can view files and clone it, but cannot push or open issues or pull requests.
reValuate/website/upload/validators.py

16 lines
583 B
Python
Raw Permalink Normal View History

def imageValidate(value):
import os
from django.core.exceptions import ValidationError
ext = os.path.splitext(value.name)[1]
valid_extensions = ['.jpg', '.png', '.gif']
if not ext.lower() in valid_extensions:
raise ValidationError('Unsupported file extension.')
def videoValidate(value):
import os
from django.core.exceptions import ValidationError
ext = os.path.splitext(value.name)[1]
valid_extensions = ['.mp4', '.mkv', '.avi']
if not ext.lower() in valid_extensions:
raise ValidationError('Unsupported file extension.')