mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
46 lines
983 B
TypeScript
46 lines
983 B
TypeScript
import { z } from '@/deps.ts';
|
|
|
|
type ElixirValue =
|
|
| string
|
|
| number
|
|
| boolean
|
|
| null
|
|
| ElixirTuple
|
|
| ElixirValue[]
|
|
| { [key: string]: ElixirValue };
|
|
|
|
interface ElixirTuple {
|
|
tuple: [string, ElixirValue];
|
|
}
|
|
|
|
interface Config {
|
|
group: string;
|
|
key: string;
|
|
value: ElixirValue;
|
|
}
|
|
|
|
const baseElixirValueSchema: z.ZodType<ElixirValue> = z.union([
|
|
z.string(),
|
|
z.number(),
|
|
z.boolean(),
|
|
z.null(),
|
|
z.lazy(() => elixirValueSchema.array()),
|
|
z.lazy(() => z.record(z.string(), elixirValueSchema)),
|
|
]);
|
|
|
|
const elixirTupleSchema: z.ZodType<ElixirTuple> = z.object({
|
|
tuple: z.tuple([z.string(), z.lazy(() => elixirValueSchema)]),
|
|
});
|
|
|
|
const elixirValueSchema: z.ZodType<ElixirValue> = z.union([
|
|
baseElixirValueSchema,
|
|
elixirTupleSchema,
|
|
]);
|
|
|
|
const configSchema: z.ZodType<Config> = z.object({
|
|
group: z.string(),
|
|
key: z.string(),
|
|
value: elixirValueSchema,
|
|
});
|
|
|
|
export { type Config, configSchema, type ElixirTuple, elixirTupleSchema, type ElixirValue };
|