def validate_enum_arg(args, name, choices, allow_query=True):
    """Validate an enum argument."""
    value = args.get(name) if isinstance(args, dict) else args
    if not value:
        return
    if value == '?' and allow_query:
        return value
    lcase = value.lower()
    if lcase not in choices:
        raise ValueError('invalid value for {0}: {1}'.format(name, value))
    return lcase