Use enum to restrict values

This commit is contained in:
Nick Mowen 2022-05-27 12:39:21 -06:00
parent aa5761f716
commit 4cfbda8f92

View File

@ -277,6 +277,13 @@ class RuntimeFilterConfig(FilterConfig):
extra = Extra.ignore extra = Extra.ignore
class BoundingBoxTriggerEnum(str, Enum):
bottom_center = "bottom-center"
left_center = "left-center"
top_center = "top-center"
right_center = "right-center"
# this uses the base model because the color is an extra attribute # this uses the base model because the color is an extra attribute
class ZoneConfig(BaseModel): class ZoneConfig(BaseModel):
filters: Dict[str, FilterConfig] = Field( filters: Dict[str, FilterConfig] = Field(
@ -289,8 +296,8 @@ class ZoneConfig(BaseModel):
default_factory=list, default_factory=list,
title="List of objects that can trigger the zone.", title="List of objects that can trigger the zone.",
) )
bounding_box_trigger: str = Field( bounding_box_trigger: BoundingBoxTriggerEnum = Field(
default="bottom-center", default=BoundingBoxTriggerEnum.bottom_center,
title="Point of an objects bounding box that triggers this zone.", title="Point of an objects bounding box that triggers this zone.",
) )
_color: Optional[Tuple[int, int, int]] = PrivateAttr() _color: Optional[Tuple[int, int, int]] = PrivateAttr()