Skip to content

Commit b1cf882

Browse files
committed
api: Add validation check on date when creating purchase
1 parent 83e2e14 commit b1cf882

File tree

1 file changed

+4
-0
lines changed
  • packages/api/services/collection/purchases

1 file changed

+4
-0
lines changed

packages/api/services/collection/purchases/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ export default ({ _socket }: UserServices) => ({
2727
date: new Date(date),
2828
description,
2929
};
30+
if (Number.isNaN(criteria.date.getTime())) {
31+
return { error: `Invalid date: ${date}` } as const;
32+
}
33+
3034
if (
3135
(await prismaDm.purchase.count({
3236
where: criteria,

0 commit comments

Comments
 (0)