Skip to content

Commit e9cac0a

Browse files
committed
fix
1 parent 3cbf004 commit e9cac0a

File tree

1 file changed

+7
-11
lines changed
  • packages/runtime/src/client/crud/validator

1 file changed

+7
-11
lines changed

packages/runtime/src/client/crud/validator/index.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -279,17 +279,13 @@ export class InputValidator<Schema extends SchemaDef> {
279279
]),
280280
)
281281
.with('Decimal', () => {
282-
const options: [z.ZodSchema, z.ZodSchema, ...z.ZodSchema[]] = [
283-
z.number(),
284-
z.instanceof(Decimal),
285-
z.string(),
286-
];
287-
if (this.extraValidationsEnabled) {
288-
for (let i = 0; i < options.length; i++) {
289-
options[i] = addDecimalValidation(options[i]!, attributes);
290-
}
291-
}
292-
return z.union(options);
282+
return z.union([
283+
this.extraValidationsEnabled ? addNumberValidation(z.number(), attributes) : z.number(),
284+
this.extraValidationsEnabled
285+
? addDecimalValidation(z.instanceof(Decimal), attributes)
286+
: z.instanceof(Decimal),
287+
this.extraValidationsEnabled ? addDecimalValidation(z.string(), attributes) : z.string(),
288+
]);
293289
})
294290
.with('DateTime', () => z.union([z.date(), z.string().datetime()]))
295291
.with('Bytes', () => z.instanceof(Uint8Array))

0 commit comments

Comments
 (0)