mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-07-31 16:12:19 +03:00
Add config validators (#22704)
* add validator for detect width and height require both or neither * coerce semantic search model string to enum Built-in model names (jinav1, jinav2) get converted to the enum, genai provider names that don't match stay as plain strings and follow the existing validation path * formatting
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import Field
|
||||
from pydantic import Field, model_validator
|
||||
|
||||
from ..base import FrigateBaseModel
|
||||
|
||||
@@ -88,3 +88,11 @@ class DetectConfig(FrigateBaseModel):
|
||||
title="Annotation offset",
|
||||
description="Milliseconds to shift detect annotations to better align timeline bounding boxes with recordings; can be positive or negative.",
|
||||
)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_dimensions(self) -> "DetectConfig":
|
||||
if (self.width is None) != (self.height is None):
|
||||
raise ValueError(
|
||||
"detect -> both width and height must be specified together, or both omitted"
|
||||
)
|
||||
return self
|
||||
|
||||
Reference in New Issue
Block a user