Skip to content

Commit

Permalink
fix allowed extensions empty
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmurilo75 committed May 8, 2024
1 parent 7530e1a commit 0466208
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions negligent_octopus/utils/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ class FileExtensionValidator:
allowed_extensions: Iterable

def __init__(self, allowed_extensions):
self.allowed_extensions = (ext.lower() for ext in allowed_extensions)
self.allowed_extensions = [ext.lower() for ext in allowed_extensions]

def __call__(self, value):
ext = get_filename_extension(value.name)
if ext.lower() not in self.allowed_extensions:
allowed_ext = ", ".join(self.allowed_extensions)
msg = f"Only {allowed_ext} file types are allowed."
msg = "Only {} file types are allowed.".format(
", ".join(self.allowed_extensions),
)
raise ValidationError(
msg,
)

0 comments on commit 0466208

Please sign in to comment.