Skip to content

Commit

Permalink
Add validation for future expiry date in coupon.validators.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarthak-ONS committed Mar 7, 2024
1 parent 79541d5 commit 46b6729
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/validators/apps/ecommerce/coupon.validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ const createCouponValidator = () => {
.notEmpty()
.withMessage("Expiry date is required")
.isISO8601()
.withMessage("Invalid expiry date. Date must be in ISO8601 format"),
.withMessage("Invalid expiry date. Date must be in ISO8601 format")
.isAfter(new Date().toISOString())
.withMessage("Expiry date must be a future date"),
];
};

Expand Down Expand Up @@ -101,7 +103,9 @@ const updateCouponValidator = () => {
.notEmpty()
.withMessage("Expiry date is required")
.isISO8601()
.withMessage("Invalid expiry date. Date must be in ISO8601 format"),
.withMessage("Invalid expiry date. Date must be in ISO8601 format")
.isAfter(new Date().toISOString())
.withMessage("Expiry date must be a future date"),
];
};

Expand Down

0 comments on commit 46b6729

Please sign in to comment.