data-validation-proximity 1.2.5 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +26 -20
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -139,7 +139,7 @@ const policySchema = joi
|
|
|
139
139
|
notification: joi
|
|
140
140
|
.object({
|
|
141
141
|
realtime: joi.boolean().allow(null).required(),
|
|
142
|
-
time: joi.
|
|
142
|
+
time: joi.number().allow(null).required(),
|
|
143
143
|
perOrdersNbr: joi.number().allow(null).required(),
|
|
144
144
|
sendMode: joi
|
|
145
145
|
.object({
|
|
@@ -438,11 +438,11 @@ exports.orderSchemaValidation = createValidationMiddleware(orderSchema);
|
|
|
438
438
|
|
|
439
439
|
const variantSchema = joi.object({
|
|
440
440
|
_id: joi.string(),
|
|
441
|
-
name: joi.string().min(3),
|
|
442
|
-
|
|
441
|
+
name: joi.string().min(3).optional(),
|
|
442
|
+
description: joi.string().min(3).max(200).optional(),
|
|
443
|
+
img: joi.string().min(3),
|
|
443
444
|
price: joi.number().min(1).max(1000000),
|
|
444
|
-
|
|
445
|
-
image: joi.string().min(3).max(200),
|
|
445
|
+
quantity: joi.number().min(1).max(1000000),
|
|
446
446
|
characterstics: joi.array().items(
|
|
447
447
|
joi.object({
|
|
448
448
|
name: joi.string().min(3),
|
|
@@ -454,6 +454,7 @@ const variantSchema = joi.object({
|
|
|
454
454
|
const createVariantSchema = joi.object({
|
|
455
455
|
price: joi.number().min(1).required(),
|
|
456
456
|
quantity: joi.number().min(1).required(),
|
|
457
|
+
img: joi.string().min(3),
|
|
457
458
|
characterstics: joi.array().items(
|
|
458
459
|
joi.object({
|
|
459
460
|
name: joi.string().min(3).required(),
|
|
@@ -466,47 +467,52 @@ const updateProductSchema = joi.object({
|
|
|
466
467
|
name: joi.string().min(3),
|
|
467
468
|
sellerId: joi.string().required(),
|
|
468
469
|
price: joi.number().min(1).max(1000000),
|
|
469
|
-
description: joi.string().min(3).max(
|
|
470
|
+
description: joi.string().min(3).max(800),
|
|
470
471
|
tags: joi.array().items(joi.string().min(3)),
|
|
471
472
|
discount: joi.number().min(0).max(100),
|
|
472
|
-
|
|
473
|
+
image: joi.string().min(3),
|
|
474
|
+
images: joi.array().items(joi.string().min(3)),
|
|
473
475
|
storeId: joi.string().required(),
|
|
474
476
|
categoryId: joi.string(),
|
|
475
477
|
storeCategoryId: joi.string(),
|
|
476
478
|
subCategoryId: joi.string(),
|
|
479
|
+
subcategory: joi.string().min(3).optional(),
|
|
477
480
|
rayonId: joi.string(),
|
|
478
|
-
|
|
481
|
+
variants: joi.array().items(variantSchema),
|
|
479
482
|
policy: policySchema,
|
|
483
|
+
discountType: joi.string(),
|
|
484
|
+
discountExpiration: joi.string(),
|
|
480
485
|
});
|
|
481
486
|
|
|
482
487
|
exports.updateProductSchemaValidation = createValidationMiddleware(updateProductSchema, (req) => {
|
|
483
|
-
parseJsonFields(req, ['
|
|
484
|
-
console.log('req.body.
|
|
488
|
+
parseJsonFields(req, ['variants', 'policy']);
|
|
489
|
+
console.log('req.body.variants:', req.body.variants);
|
|
485
490
|
});
|
|
486
491
|
|
|
487
492
|
const createProductSchema = joi.object({
|
|
488
493
|
name: joi.string().min(3).required(),
|
|
489
494
|
price: joi.number().min(1).required(),
|
|
490
495
|
description: joi.string().min(3).max(800),
|
|
491
|
-
|
|
496
|
+
images: joi.array().items(joi.string().min(3)),
|
|
497
|
+
tags: joi.array().items(joi.string().min(2)),
|
|
498
|
+
sellerId: joi.string(),
|
|
499
|
+
discount: joi.number().min(1).max(100),
|
|
500
|
+
discountType: joi.string(),
|
|
501
|
+
discountExpiration: joi.string(),
|
|
502
|
+
image: joi.string().min(3),
|
|
492
503
|
storeCategoryId: joi.string().allow(''),
|
|
493
|
-
categoryId: joi.string().allow(''),
|
|
494
504
|
subCategoryId: joi.string().allow(''),
|
|
505
|
+
subcategory: joi.string().min(3).optional(),
|
|
506
|
+
categoryId: joi.string().allow(''),
|
|
495
507
|
rayonId: joi.string().allow(''),
|
|
496
|
-
subcategory: joi.string().min(3),
|
|
497
|
-
discount: joi.number().min(1).max(100),
|
|
498
|
-
tags: joi.array().items(joi.string().min(2)),
|
|
499
|
-
sellerId: joi.string(),
|
|
500
508
|
storeId: joi.string().required(),
|
|
501
|
-
|
|
502
|
-
characteristics: joi.object().pattern(joi.string(), joi.array().items(joi.string().min(1))),
|
|
503
|
-
variantes: joi.array().items(createVariantSchema),
|
|
509
|
+
variants: joi.array().items(createVariantSchema),
|
|
504
510
|
policy: policySchema,
|
|
505
511
|
});
|
|
506
512
|
|
|
507
513
|
exports.createProductSchemaValidation = createValidationMiddleware(createProductSchema, (req) => {
|
|
508
514
|
console.log('Validating product creation:', req.body);
|
|
509
|
-
parseJsonFields(req, ['
|
|
515
|
+
parseJsonFields(req, ['variants', 'policy']);
|
|
510
516
|
normalizeFileArrays(req);
|
|
511
517
|
});
|
|
512
518
|
|