diff --git a/validators/customDiscount.validator.js b/validators/customDiscount.validator.js index 753e83807738ca419a7d8f6fc5ceca57b21d59c0..c5d256fd8229bb8a3efb5488f5c9376e60ce688e 100644 --- a/validators/customDiscount.validator.js +++ b/validators/customDiscount.validator.js @@ -137,7 +137,7 @@ const customDiscountValidator = Joi.object({ // For productAdjustment, cartAdjustment, freeShipping - discountMethod is required discountMethod: Joi.string() - .valid("percentageDiscount", "flat_rate", "percentage", "free") + .valid("flat_rate", "percentage", "free") .when("discountType", { is: Joi.valid("productAdjustment", "cartAdjustment", "freeShipping"), then: Joi.required(), @@ -293,13 +293,14 @@ const updateCustomDiscountValidator = Joi.object({ discountType: Joi.string() .valid( "productAdjustment", - "cartAdjustment", + "cartAdjustment", "freeShipping", "buyXgetX", "buyXgetY" ) .messages({ - "any.only": "Discount type must be one of: productAdjustment, cartAdjustment, freeShipping, buyXgetX, buyXgetY", + "any.only": + "Discount type must be one of: productAdjustment, cartAdjustment, freeShipping, buyXgetX, buyXgetY", }), isCouponcodeBased: Joi.boolean().messages({ @@ -346,7 +347,8 @@ const updateCustomDiscountValidator = Joi.object({ }), otherwise: Joi.array().items(filterSchema).min(1), }).messages({ - "array.min": "At least one filter condition is required when applyForAllProducts is false", + "array.min": + "At least one filter condition is required when applyForAllProducts is false", }), // For productAdjustment, cartAdjustment, freeShipping - discountMethod is required @@ -358,7 +360,8 @@ const updateCustomDiscountValidator = Joi.object({ otherwise: Joi.allow(null, ""), }) .messages({ - "any.only": "Discount method must be one of: percentageDiscount, flat_rate, percentage, free", + "any.only": + "Discount method must be one of: percentageDiscount, flat_rate, percentage, free", "any.required": "Discount method is required for this discount type", }), @@ -381,7 +384,8 @@ const updateCustomDiscountValidator = Joi.object({ then: getYProductsSchema.required(), otherwise: Joi.allow(null, ""), }).messages({ - "any.required": "BOGO product details are required for buyXgetX and buyXgetY discount types", + "any.required": + "BOGO product details are required for buyXgetX and buyXgetY discount types", }), custom_meta: Joi.when("discountType", { @@ -389,7 +393,8 @@ const updateCustomDiscountValidator = Joi.object({ then: getYProductsSchema.required(), otherwise: Joi.allow(null, ""), }).messages({ - "any.required": "BOGO product details are required for buyXgetX and buyXgetY discount types", + "any.required": + "BOGO product details are required for buyXgetX and buyXgetY discount types", }), // Cart adjustment and Free shipping specific fields @@ -431,14 +436,14 @@ const updateCustomDiscountValidator = Joi.object({ per_customer_limit: Joi.number().integer().min(0).allow(null).messages({ "number.base": "Per customer limit must be a number", - "number.integer": "Per customer limit must be an integer", + "number.integer": "Per customer limit must be an integer", "number.min": "Per customer limit cannot be negative", }), }) -.min(1) -.messages({ - "object.min": "At least one field must be provided for update", -}); + .min(1) + .messages({ + "object.min": "At least one field must be provided for update", + }); const validateCustomDiscountData = (req, res, next) => { const { error } = customDiscountValidator.validate(req.body, {