from django.core.exceptions import ValidationError
from django.utils.translation import gettext


class SpecialCharactersValidation:
    characters = set("!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~")

    # pylint: disable=unused-argument
    def validate(self, password, user=None):
        if set(password).isdisjoint(self.characters):
            raise ValidationError(
                gettext(
                    "The password does not contain any special characters.",
                ),
                code="password_must_contain_special_characters",
            )

    def get_help_text(self):
        return gettext("Your password must contain at least 1 special character.")
