def validate_args(numargs, args):
    """
    Check that there are enough args in the list, and truncate accordingly.

    Raises ValueError if not.
    """
    if len(args) < numargs:
        raise ValueError("Not enough elements in list {}, need "
                         "{}.".format(args, numargs))

    return args