def check_password(pw):
    """
    Enforce password strength rules.

    Returns the password if it passes, otherwises raises ``ValidationError``.

    """
    if len(pw) < settings.MINIMUM_PASSWORD_CHARS:
        raise forms.ValidationError(
            "Your password must be a minimum of {0} characters.".format(
                settings.MINIMUM_PASSWORD_CHARS)
            )
    if (settings.PASSWORD_REQUIRE_ALPHA_NUMERIC and
        not (any(c.isdigit() for c in pw) and any(c.isalpha() for c in pw))
        ):
        raise forms.ValidationError(
            "Your password must contain both letters and numbers.")
    if pw in settings.FORBIDDEN_PASSWORDS:
        raise forms.ValidationError(
            "That password is too easily guessed; please choose a different one.")
    return pw
dataset/ETHPy150Open mozilla/moztrap/moztrap/view/users/forms.py/check_password/original