def check_multiplicity(par, values, bundle_length):
    """
    Check the number of values for the parameter against bundle length,
    depending on whether the parameter is required or multiple.
    """
    name = par['name']
    required = par['required']
    multiple = par['multiple']
    if required and len(values) == 0:
        raise ValueError('need a value for %s' % name)
    if not multiple and len(values) not in [0, 1, bundle_length]:
        raise ValueError('wrong number of values for %s' % name)
