2025-02-12 23:04:44 +01:00
|
|
|
import ISO6391 from "iso-639-1";
|
2025-03-29 03:30:06 +01:00
|
|
|
import { z } from "zod";
|
2025-02-05 22:49:07 +01:00
|
|
|
|
|
|
|
|
export const Id = z.string().uuid();
|
2025-02-12 23:04:44 +01:00
|
|
|
|
2025-03-24 15:25:40 +01:00
|
|
|
export const iso631 = z
|
|
|
|
|
.enum(ISO6391.getAllCodes() as [string, ...string[]])
|
2025-03-29 03:30:06 +01:00
|
|
|
.openapi({
|
|
|
|
|
description: "ISO 639-1 language code",
|
|
|
|
|
example: "en",
|
|
|
|
|
externalDocs: {
|
|
|
|
|
url: "https://en.wikipedia.org/wiki/List_of_ISO_639-1_language_codes",
|
|
|
|
|
},
|
|
|
|
|
ref: "ISO631",
|
|
|
|
|
});
|
2025-02-15 02:47:29 +01:00
|
|
|
|
|
|
|
|
export const zBoolean = z
|
|
|
|
|
.string()
|
|
|
|
|
.transform((v) => ["true", "1", "on"].includes(v.toLowerCase()))
|
2025-03-29 03:30:06 +01:00
|
|
|
.openapi({ type: "boolean" })
|
2025-02-15 02:47:29 +01:00
|
|
|
.or(z.boolean());
|