File size: 359 Bytes
2606dde
151571d
2606dde
 
cf7ac8d
151571d
 
 
cf7ac8d
151571d
1
2
3
4
5
6
7
8
9
10
11
import type { Model } from "$lib/types/Model";
import { z } from "zod";

export const findCurrentModel = (models: Model[], name?: string) =>
	models.find((m) => m.id === name) ?? models[0];

export const validateModel = (models: Model[]) => {
	// Zod enum function requires 2 parameters
	return z.enum([models[0].id, ...models.slice(1).map((m) => m.id)]);
};