import unicodedata

from django.core.exceptions import ValidationError
from django.utils.translation import gettext_lazy as _

# Useful for translation
to_be_translated = [_("mean"), _("median"), _("maximum"), _("minimum"), _("stdev")]


def no_slash_validator(value):
    if "/" in value:
        raise ValidationError(_("The '/' character is not allowed."))


def remove_accents(input_str):
    if input_str is None:
        return None
    nfkd_form = unicodedata.normalize("NFKD", input_str)
    return "".join([c for c in nfkd_form if not unicodedata.combining(c)])
