web: Use Zod z.discriminatedUnion more.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2024-03-02 12:14:53 -08:00
committed by Anders Kaseorg
parent a03a26151c
commit aaa6f16538
2 changed files with 6 additions and 3 deletions

View File

@@ -36,7 +36,7 @@ const draft_schema = z.intersection(
content: z.string(),
updatedAt: z.number(),
}),
z.union([
z.discriminatedUnion("type", [
z.object({
type: z.literal("stream"),
topic: z.string(),
@@ -61,7 +61,7 @@ const possibly_buggy_draft_schema = z.intersection(
content: z.string(),
updatedAt: z.number(),
}),
z.union([
z.discriminatedUnion("type", [
z.object({
type: z.literal("stream"),
topic: z.string().optional(),