'This function is responsible for validating users (if present).
@type return_bool: bool
@param return_bool: True when we are only interested in the result of the
validation, and not the validated rule itself.
@type valid_rule: bool
@param valid_rule: returns True if everything is valid. False if it encounters any
abnormalities in the config.
@type original_rule: dict
@param original_rule: contains the original received rule
@type counter: int
@param counter: this counter is used to identify what rule # is currently being
validated. Necessary for log output.
@type tool: str
@param tool: the name of the current tool. Necessary for log output.
@rtype: bool, dict (tuple)
@return: validated rule and result of validation'

@classmethod
def __validate_users(cls, valid_rule, return_bool, rule, tool, counter):

    emailregex = '^[A-Za-z0-9\\.\\+_-]+@[A-Za-z0-9\\._-]+\\.[a-zA-Z]*$'
    if ('users' in rule):
        if isinstance(rule['users'], list):
            for user in reversed(rule['users']):
                if (not isinstance(user, str)):
                    error = (("Entry    '" + str(user)) + "'    in    users    for    rule    ")
                    error += (((str(counter) + "    in    tool    '") + str(tool)) + "'    is    in    an    ")
                    error += 'invalid    format!'
                    if (not return_bool):
                        error += '    Ignoring    entry.'
                    if verbose:
                        log.debug(error)
                    valid_rule = False
                    rule['users'].remove(user)
                elif (re.match(emailregex, user) is None):
                    error = (("Supplied    email    '" + str(user)) + "'    for    rule    ")
                    error += (((str(counter) + "    in    tool    '") + str(tool)) + "'    is    in    ")
                    error += 'an    invalid    format!'
                    if (not return_bool):
                        error += '    Ignoring    email.'
                    if verbose:
                        log.debug(error)
                    valid_rule = False
                    rule['users'].remove(user)
        else:
            error = "Couldn't    find    a    list    under    'users:'!"
            if (not return_bool):
                error += '    Ignoring    rule.'
                rule = None
            if verbose:
                log.debug(error)
            valid_rule = False
        if ((rule is not None) and (rule['users'] is not None) and (len(rule['users']) == 0)):
            error = ('No    valid    user    emails    were    specified    for    rule    ' + str(counter))
            error += (("    in    tool    '" + str(tool)) + "'!")
            if (not return_bool):
                error += '    Ignoring    rule.'
                rule = None
            if verbose:
                log.debug(error)
            valid_rule = False
    return (valid_rule, rule)
