10 lines
447 B
Python
10 lines
447 B
Python
from django.core.exceptions import ValidationError
|
|
from django.conf import settings
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
class LanguageValidator:
|
|
def __call__(self, value):
|
|
for language, _ in settings.LANGUAGES:
|
|
if language.startswith(value):
|
|
return
|
|
raise ValidationError(_("This is not a valid language code supported by this project."), code='invalid', params={'value': value})
|