def METHOD_NAME(self, value: bool) -> bool:
    """Ensure user and password attributes are set"""
    if value:
        if (
            self.initial_data.get("basic_auth_password_attribute", "") == ""
            or self.initial_data.get("basic_auth_user_attribute", "") == ""
        ):
            raise ValidationError(
                _("User and password attributes must be set when basic auth is enabled.")
            )
    return value