Adrien Denat
make sure we allow user to change model if clicking on a link with mo… (#172)
151571d unverified
raw
history blame
No virus
365 Bytes
import type { Model } from "$lib/types/Model";
import { z } from "zod";
export const findCurrentModel = (models: Model[], name?: string) =>
models.find((m) => m.name === name) ?? models[0];
export const validateModel = (models: Model[]) => {
// Zod enum function requires 2 parameters
return z.enum([models[0].name, ...models.slice(1).map((m) => m.name)]);
};