Skip to content

Commit

Permalink
fix: transform
Browse files Browse the repository at this point in the history
  • Loading branch information
xhyrom committed Feb 13, 2022
1 parent 6da8f7b commit 0b9d4c4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/lib/structures/Argument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ const validationSchema = z
arguments: z.any().array().optional(),
channelTypes: z
.union([z.string(), z.nativeEnum(ChannelType)])
.transform((arg) => (Object.keys(ChannelType).includes(String(arg)) ? ChannelType[arg] : arg))
.transform((arg) =>
typeof arg === 'string' && Object.keys(ChannelType).includes(arg) ? ChannelType[arg] : arg,
)
.array()
.optional(),
run: z.function().optional(),
Expand Down
2 changes: 1 addition & 1 deletion src/lib/structures/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const validationSchema = z
cooldown: z.string().optional(),
autoDefer: z
.union([z.string(), z.nativeEnum(AutoDeferType)])
.transform((arg) => (Object.keys(AutoDeferType).includes(String(arg)) ? AutoDeferType[arg] : arg))
.transform((arg) => (typeof arg === 'string' && Object.keys(AutoDeferType).includes(arg) ? AutoDeferType[arg] : arg))
.optional(),
fileName: z.string().optional(),
run: z.function(),
Expand Down
2 changes: 1 addition & 1 deletion src/lib/structures/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const validationSchema = z
cooldown: z.string().optional(),
autoDefer: z
.union([z.string(), z.nativeEnum(AutoDeferType)])
.transform((arg) => (Object.keys(AutoDeferType).includes(String(arg)) ? AutoDeferType[arg] : arg))
.transform((arg) => (typeof arg === 'string' && Object.keys(AutoDeferType).includes(arg) ? AutoDeferType[arg] : arg))
.optional(),
fileName: z.string().optional(),
run: z.function(),
Expand Down

0 comments on commit 0b9d4c4

Please sign in to comment.