Improve error location reporting (w/fixed zod).

This commit is contained in:
Dermot Duffy
2021-10-17 20:25:26 -07:00
parent fd76909d9b
commit 9ae66d75ef
4 changed files with 53 additions and 7 deletions
+9 -1
View File
@@ -195,7 +195,15 @@ const conditionalSchema = z.object({
// https://www.home-assistant.io/lovelace/picture-elements/#custom-elements
const customSchema = z.object({
// Insist that Frigate card custom elements are handled by other schemas.
type: z.string().regex(/^custom:(?!frigate-card).+/),
type: z.string().superRefine((val, ctx) => {
if (!val.match(/^custom:(?!frigate-card).+/)) {
ctx.addIssue({
code: z.ZodIssueCode.invalid_type,
expected: "string",
received: "string",
});
}
})
}).passthrough();
/**