[GH-ISSUE #8974] Replace z.union + z.undefined() with z.xor() for mutually exclusive fields #19880

Closed
opened 2026-04-15 19:14:17 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @bytaesu on GitHub (Apr 5, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/8974

organization.ts and admin/routes.ts use

z.union([
  z.object({ a: ..., b: z.undefined() }),
  z.object({ a: z.undefined(), b: ... })
]) to enforce mutually exclusive permission/permissions fields.

https://zod.dev/api?id=exclusive-unions-xor

Zod v4 z.xor() expresses this intent directly. No behavioral change.

Originally created by @bytaesu on GitHub (Apr 5, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/8974 `organization.ts` and `admin/routes.ts` use ```ts z.union([ z.object({ a: ..., b: z.undefined() }), z.object({ a: z.undefined(), b: ... }) ]) to enforce mutually exclusive permission/permissions fields. ``` > https://zod.dev/api?id=exclusive-unions-xor Zod v4 `z.xor()` expresses this intent directly. No behavioral change.
GiteaMirror added the enhancementgood first issue labels 2026-04-15 19:14:17 -05:00
Author
Owner

@rajanarahul93 commented on GitHub (Apr 6, 2026):

Hey @bytaesu , will work on this and create a pr shortly!!

<!-- gh-comment-id:4191460012 --> @rajanarahul93 commented on GitHub (Apr 6, 2026): Hey @bytaesu , will work on this and create a pr shortly!!
Author
Owner

@Saiyaswanthpasupuleti commented on GitHub (Apr 6, 2026):

hey @rajanarahul93 i have a pr for this one #8982

<!-- gh-comment-id:4191505845 --> @Saiyaswanthpasupuleti commented on GitHub (Apr 6, 2026): hey @rajanarahul93 i have a pr for this one #8982
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#19880