'Helper function to determine the validity of a policy name. Used
to check policy names before setting them.
:param name: a name string for a single policy name.
:raises PolicyError: if the policy name is invalid.'

def _validate_policy_name(self, name):

    if (not name):
        raise PolicyError(('Invalid    name    %r' % name), self.idx)
    if (not all(((c in VALID_CHARS) for c in name))):
        msg = ('Names    are    used    as    HTTP    headers,    and    can    not    reliably    contain    any    characters    not    in    %r.    Invalid    name    %r' % (VALID_CHARS, name))
        raise PolicyError(msg, self.idx)
    if ((name.upper() == LEGACY_POLICY_NAME.upper()) and (self.idx != 0)):
        msg = ('The    name    %s    is    reserved    for    policy    index    0.    Invalid    name    %r' % (LEGACY_POLICY_NAME, name))
        raise PolicyError(msg, self.idx)
    if (name.upper() in (existing_name.upper() for existing_name in self.alias_list)):
        msg = ('The    name    %s    is    already    assigned    to    this    policy.' % name)
        raise PolicyError(msg, self.idx)
