data-validation-proximity 1.3.17 → 1.4.1

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.
Files changed (2) hide show
  1. package/index.js +184 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -70,11 +70,13 @@ const policySchema = joi
70
70
  .allow(null),
71
71
  pickup: joi
72
72
  .object({
73
+ enabled: joi.boolean().allow(null),
73
74
  timeLimit: joi.number().required(),
74
75
  })
75
76
  .allow(null),
76
77
  delivery: joi
77
78
  .object({
79
+ enabled: joi.boolean().allow(null),
78
80
  delivery: joi.boolean().required().allow(null),
79
81
  })
80
82
  .allow(null),
@@ -154,6 +156,21 @@ const policySchema = joi
154
156
  .allow(null),
155
157
  })
156
158
  .allow(null),
159
+ payment: joi
160
+ .object({
161
+ enabled: joi.boolean().allow(null),
162
+ paymentTypeIds: joi.array().items(joi.string()).allow(null),
163
+ credentials: joi
164
+ .array()
165
+ .items(
166
+ joi.object({
167
+ paymentTypeId: joi.string().required(),
168
+ keys: joi.object().pattern(joi.string(), joi.string()).allow(null),
169
+ })
170
+ )
171
+ .allow(null),
172
+ })
173
+ .allow(null),
157
174
  })
158
175
  .allow(null);
159
176
 
@@ -205,6 +222,11 @@ const userSchema = joi.object({
205
222
  password: joi.string().min(6).required(),
206
223
  password_confirmation: joi.string().min(6).required(),
207
224
  role: joi.string().valid(...validRoles).required(),
225
+ sellerType: joi
226
+ .string()
227
+ .valid('physical_merchant', 'mobile_merchant', 'producer', 'e_merchant')
228
+ .allow(null)
229
+ .optional(),
208
230
  cart: joi.string().allow(null).allow(''),
209
231
  google: joi.boolean(),
210
232
  profileImage: joi.string(),
@@ -307,6 +329,11 @@ const updateSchema = joi.object({
307
329
  profileImage: joi.string().min(3).max(200),
308
330
  adresse: addressSchema,
309
331
  policy: policySchema,
332
+ sellerType: joi
333
+ .string()
334
+ .valid('physical_merchant', 'mobile_merchant', 'producer', 'e_merchant')
335
+ .allow(null)
336
+ .optional(),
310
337
  discountCode: joi.string().min(3),
311
338
  companyName: joi.string().min(3),
312
339
  shippingAdress: joi.object({
@@ -328,6 +355,7 @@ const updateSchema = joi.object({
328
355
  proximityRange: joi.number().min(0).max(1000),
329
356
  preferredLanguage: joi.string().valid('en', 'fr', 'ar').optional(),
330
357
  currency: joi.string().optional(),
358
+ mobilePaymentManager: joi.boolean(),
331
359
  });
332
360
 
333
361
  exports.updateSchemaValidation = createValidationMiddleware(updateSchema, (req) => {
@@ -492,6 +520,7 @@ const updateProductSchema = joi.object({
492
520
  policy: policySchema,
493
521
  discountType: joi.string(),
494
522
  discountExpiration: joi.string(),
523
+ confirmed: joi.boolean().optional(),
495
524
  });
496
525
 
497
526
  exports.updateProductSchemaValidation = createValidationMiddleware(updateProductSchema, (req) => {
@@ -519,6 +548,7 @@ const createProductSchema = joi.object({
519
548
  storeId: joi.string().required(),
520
549
  variants: joi.array().items(createVariantSchema),
521
550
  policy: policySchema,
551
+ confirmed: joi.boolean().optional(),
522
552
  });
523
553
 
524
554
  exports.createProductSchemaValidation = createValidationMiddleware(createProductSchema, (req) => {
@@ -583,11 +613,87 @@ const schemaStore = joi.object({
583
613
  storeRayons: joi.string().allow('').allow(null),
584
614
  template: joi.string(),
585
615
  registrationNumber: joi.string(),
616
+ confirmed: joi.boolean().optional(),
617
+ physicalMerchantInfo: joi
618
+ .object({
619
+ approximateSurface: joi.number().allow(null),
620
+ shopPhotos: joi.array().items(joi.string()).allow(null),
621
+ })
622
+ .allow(null)
623
+ .optional(),
624
+ mobileMerchantInfo: joi
625
+ .object({
626
+ coveredZones: joi
627
+ .array()
628
+ .items(
629
+ joi.object({
630
+ city: joi.string().allow('').allow(null),
631
+ region: joi.string().allow('').allow(null),
632
+ latitude: joi.number().allow(null),
633
+ longitude: joi.number().allow(null),
634
+ })
635
+ )
636
+ .allow(null),
637
+ realTimePosition: joi.boolean().allow(null),
638
+ marketCalendar: joi
639
+ .array()
640
+ .items(
641
+ joi.object({
642
+ date: joi.string().allow('').allow(null),
643
+ location: joi.string().allow('').allow(null),
644
+ marketName: joi.string().allow('').allow(null),
645
+ })
646
+ )
647
+ .allow(null),
648
+ standPhoto: joi.string().allow('').allow(null),
649
+ visibleName: joi.string().allow('').allow(null),
650
+ })
651
+ .allow(null)
652
+ .optional(),
653
+ producerInfo: joi
654
+ .object({
655
+ productionType: joi.string().allow('').allow(null),
656
+ productionMethods: joi.array().items(joi.string()).allow(null),
657
+ visitPossible: joi.boolean().allow(null),
658
+ labels: joi
659
+ .array()
660
+ .items(
661
+ joi.object({
662
+ title: joi.string().allow('').allow(null),
663
+ link: joi.string().allow('').allow(null),
664
+ })
665
+ )
666
+ .allow(null),
667
+ directSale: joi.boolean().allow(null),
668
+ saleLocations: joi
669
+ .array()
670
+ .items(
671
+ joi.object({
672
+ name: joi.string().allow('').allow(null),
673
+ latitude: joi.number().allow(null),
674
+ longitude: joi.number().allow(null),
675
+ })
676
+ )
677
+ .allow(null),
678
+ deliveryScope: joi.string().valid('local', 'national').allow(null),
679
+ availableQuantities: joi.string().valid('small_series', 'volume', 'both').allow(null),
680
+ })
681
+ .allow(null)
682
+ .optional(),
683
+ eMerchantInfo: joi
684
+ .object({
685
+ websiteUrl: joi.string().allow('').allow(null),
686
+ platform: joi.string().allow('').allow(null),
687
+ onlineShopName: joi.string().allow('').allow(null),
688
+ approximateProductCount: joi.number().allow(null),
689
+ })
690
+ .allow(null)
691
+ .optional(),
586
692
  });
587
693
 
588
694
  exports.schemaStoreValidation = (req, res, next) => {
589
695
  console.log('Start store validation');
590
- parseJsonFields(req, ['location', 'address', 'policy', 'workingTime']);
696
+ parseJsonFields(req, ['location', 'address', 'policy', 'workingTime', 'physicalMerchantInfo', 'mobileMerchantInfo', 'producerInfo', 'eMerchantInfo']);
591
697
  console.log('Parsed workingTime:', req.body.workingTime);
592
698
 
593
699
  const { error } = schemaStore.validate(req.body);
@@ -616,10 +722,86 @@ const schemaUpdateStore = joi.object({
616
722
  storeRayons: joi.string().allow('').allow(null),
617
723
  template: joi.string(),
618
724
  registrationNumber: joi.string(),
725
+ confirmed: joi.boolean().optional(),
726
+ physicalMerchantInfo: joi
727
+ .object({
728
+ approximateSurface: joi.number().allow(null),
729
+ shopPhotos: joi.array().items(joi.string()).allow(null),
730
+ })
731
+ .allow(null)
732
+ .optional(),
733
+ mobileMerchantInfo: joi
734
+ .object({
735
+ coveredZones: joi
736
+ .array()
737
+ .items(
738
+ joi.object({
739
+ city: joi.string().allow('').allow(null),
740
+ region: joi.string().allow('').allow(null),
741
+ latitude: joi.number().allow(null),
742
+ longitude: joi.number().allow(null),
743
+ })
744
+ )
745
+ .allow(null),
746
+ realTimePosition: joi.boolean().allow(null),
747
+ marketCalendar: joi
748
+ .array()
749
+ .items(
750
+ joi.object({
751
+ date: joi.string().allow('').allow(null),
752
+ location: joi.string().allow('').allow(null),
753
+ marketName: joi.string().allow('').allow(null),
754
+ })
755
+ )
756
+ .allow(null),
757
+ standPhoto: joi.string().allow('').allow(null),
758
+ visibleName: joi.string().allow('').allow(null),
759
+ })
760
+ .allow(null)
761
+ .optional(),
762
+ producerInfo: joi
763
+ .object({
764
+ productionType: joi.string().allow('').allow(null),
765
+ productionMethods: joi.array().items(joi.string()).allow(null),
766
+ visitPossible: joi.boolean().allow(null),
767
+ labels: joi
768
+ .array()
769
+ .items(
770
+ joi.object({
771
+ title: joi.string().allow('').allow(null),
772
+ link: joi.string().allow('').allow(null),
773
+ })
774
+ )
775
+ .allow(null),
776
+ directSale: joi.boolean().allow(null),
777
+ saleLocations: joi
778
+ .array()
779
+ .items(
780
+ joi.object({
781
+ name: joi.string().allow('').allow(null),
782
+ latitude: joi.number().allow(null),
783
+ longitude: joi.number().allow(null),
784
+ })
785
+ )
786
+ .allow(null),
787
+ deliveryScope: joi.string().valid('local', 'national').allow(null),
788
+ availableQuantities: joi.string().valid('small_series', 'volume', 'both').allow(null),
789
+ })
790
+ .allow(null)
791
+ .optional(),
792
+ eMerchantInfo: joi
793
+ .object({
794
+ websiteUrl: joi.string().allow('').allow(null),
795
+ platform: joi.string().allow('').allow(null),
796
+ onlineShopName: joi.string().allow('').allow(null),
797
+ approximateProductCount: joi.number().allow(null),
798
+ })
799
+ .allow(null)
800
+ .optional(),
619
801
  });
620
802
 
621
803
  exports.schemaUpdateStoreValidation = (req, res, next) => {
622
- parseJsonFields(req, ['location', 'address', 'policy', 'workingTime']);
804
+ parseJsonFields(req, ['location', 'address', 'policy', 'workingTime', 'physicalMerchantInfo', 'mobileMerchantInfo', 'producerInfo', 'eMerchantInfo']);
623
805
  console.log('Parsed workingTime:', req.body.workingTime);
624
806
 
625
807
  const { error } = schemaUpdateStore.validate(req.body);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "data-validation-proximity",
3
- "version": "1.3.17",
3
+ "version": "1.4.1",
4
4
  "description": "A library of Joi-based validation middlewares for Express.js",
5
5
  "main": "index.js",
6
6
  "license": "MIT",