diff --git a/api-openbis-python3-pybis/src/python/pybis/property.py b/api-openbis-python3-pybis/src/python/pybis/property.py index 54b8577de72f50f76309aa0d3e8baa7af5f56698..751ccf2fccb1a91285efc82aba633b3dd43f9ae7 100644 --- a/api-openbis-python3-pybis/src/python/pybis/property.py +++ b/api-openbis-python3-pybis/src/python/pybis/property.py @@ -137,11 +137,20 @@ class PropertyHolder: data_type = property_type["dataType"] if data_type == "CONTROLLEDVOCABULARY": terms = property_type["terms"] - value = str(value).upper() - if value not in terms.df["code"].values: - raise ValueError( - f"Value for attribute «{name}» must be one of these terms: {', '.join(terms.df['code'].values)}" - ) + if "multiValue" in property_type and property_type["multiValue"] is True: + if type(value) != list: + value = [value] + for single_value in value: + if str(single_value).upper() not in terms.df["code"].values: + raise ValueError( + f"Value for attribute «{name}» must be one of these terms: {', '.join(terms.df['code'].values)}" + ) + else: + value = str(value).upper() + if value not in terms.df["code"].values: + raise ValueError( + f"Value for attribute «{name}» must be one of these terms: {', '.join(terms.df['code'].values)}" + ) elif data_type in ("INTEGER", "BOOLEAN", "VARCHAR", "ARRAY_INTEGER", "ARRAY_REAL", "ARRAY_STRING", "ARRAY_TIMESTAMP"): if not check_datatype(data_type, value): raise ValueError(f"Value must be of type {data_type}")