config validation

This commit is contained in:
Dax Raad
2025-06-20 00:57:28 -04:00
parent 6674c6083a
commit 41dba0db08
10 changed files with 174 additions and 72 deletions

View File

@@ -0,0 +1,13 @@
import { Config } from "../config/config"
export function FormatError(input: unknown) {
if (Config.JsonError.isInstance(input))
return `Config file at ${input.data.path} is not valid JSON`
if (Config.InvalidError.isInstance(input))
return [
`Config file at ${input.data.path} is invalid`,
...(input.data.issues?.map(
(issue) => "↳ " + issue.message + " " + issue.path.join("."),
) ?? []),
].join("\n")
}