Files
frigate/web/src/components/config-form/section-validations/models.ts
T
Nicolas Mowen 27a40a507b Implement UI for managing multiple models (#24023)
* Implement hardware detection and UI management

* Cleanup Frigate+ detection

* Don't count model as changed

* Fixes for audio map error

* Add descriptions

* Enforce that all model must exist

* Fix hardware picking

* Docs fixes

* WebUI cleanup

* Cleanup handling of scenes

* UI refinement

* Cleanup recommended UI

* test fixews
2026-09-12 07:30:04 -06:00

32 lines
921 B
TypeScript

import type { FormValidation } from "@rjsf/utils";
import type { TFunction } from "i18next";
import { isJsonObject } from "@/lib/utils";
const DEFAULT_SCENE = "all";
/**
* A camera that names no scene runs the model whose scene is `all`. Without one
* the backend rejects the config outright once a second model exists, and with
* a single model it silently runs every camera on whatever that model is. Both
* are surprising, so require the default to be present.
*/
export function validateDefaultModelExists(
formData: unknown,
errors: FormValidation,
t: TFunction,
): FormValidation {
if (!Array.isArray(formData) || formData.length === 0) {
return errors;
}
const hasDefault = formData.some(
(model) => isJsonObject(model) && model.scene === DEFAULT_SCENE,
);
if (!hasDefault) {
errors.addError?.(t("models.defaultRequired", { ns: "config/validation" }));
}
return errors;
}