Skip to content

Commit 84a0366

Browse files
committed
components: cart[cart_validation]
1 parent 864f66a commit 84a0366

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

components/cart/cart_validation.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import Joi from "joi";
2+
3+
const addProductToCartValidation = Joi.object({
4+
cartItem: Joi.array()
5+
.items(
6+
Joi.object({
7+
productId: Joi.string().hex().length(24).required(),
8+
quantity: Joi.number().integer().min(1).default(1),
9+
price: Joi.number().min(0).required(),
10+
totalProductDiscount: Joi.number().min(0).required(),
11+
})
12+
)
13+
.min(1),
14+
});
15+
16+
const removeProductFromCart = Joi.object({
17+
productId: Joi.string().hex().length(24).required(),
18+
});
19+
export { addProductToCartValidation, removeProductFromCart };

0 commit comments

Comments
 (0)