[python] Check if the given input is a container (Array or Map) when validating enum values (#19316)

* checks if input is Array or Map in validate_enum

* update samples
This commit is contained in:
vcutrona
2024-10-10 08:57:04 +02:00
committed by GitHub
parent ea4b17c32f
commit 45fa4384e7
3 changed files with 15 additions and 6 deletions

View File

@@ -38,8 +38,9 @@ class MapTest(BaseModel):
if value is None:
return value
if value not in set(['UPPER', 'lower']):
raise ValueError("must be one of enum values ('UPPER', 'lower')")
for i in value.values():
if i not in set(['UPPER', 'lower']):
raise ValueError("dict values must be one of enum values ('UPPER', 'lower')")
return value
model_config = ConfigDict(