- spac.utils.check_list_in_list(input, input_name, input_type, target_list, need_exist=True, warning=False)[source]
Check if items in a given list exist in a target list.
This function is used to validate whether all or none of the items in a given list exist in a target list. It helps to ensure that the input list contains only valid elements that are present in the target list.
- Parameters:
input (str or list of str or None) – The input list or a single string element. If it is a string, it will be converted to a list containing only that string element. If None, no validation will be performed.
input_name (str) – The name of the input list used for displaying helpful error messages.
input_type (str) – The type of items in the input list (e.g., “item”, “element”, “category”).
target_list (list of str) – The target list containing valid items that the input list elements should be compared against.
need_exist (bool, optional (default=True)) –
- Determines whether to check if elements exist in the
target list (True), or if they should not exist (False).
- warning: bool, optional (default=False)
If true, generate a warning instead of raising an exception
- Raises:
ValueError – If the input is not a string or a list of strings. If need_exist is True and any element of the input list does not exist in the target list. If need_exist is False and any element of the input list exists in the target list.
- Warns:
UserWarning – If the specified behavior is not present and warning is True.