data-validation-proximity 1.3.16 → 1.4.0

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 +185 -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(),
@@ -231,6 +253,7 @@ const userSchema = joi.object({
231
253
  }),
232
254
  preferredLanguage: joi.string().valid('en', 'fr', 'ar').optional(),
233
255
  companyName: joi.string().optional(),
256
+ currency: joi.string().optional(),
234
257
  });
235
258
 
236
259
  exports.userSchemaValidation = createValidationMiddleware(userSchema);
@@ -306,6 +329,11 @@ const updateSchema = joi.object({
306
329
  profileImage: joi.string().min(3).max(200),
307
330
  adresse: addressSchema,
308
331
  policy: policySchema,
332
+ sellerType: joi
333
+ .string()
334
+ .valid('physical_merchant', 'mobile_merchant', 'producer', 'e_merchant')
335
+ .allow(null)
336
+ .optional(),
309
337
  discountCode: joi.string().min(3),
310
338
  companyName: joi.string().min(3),
311
339
  shippingAdress: joi.object({
@@ -326,6 +354,7 @@ const updateSchema = joi.object({
326
354
  notification: joi.string().allow(null),
327
355
  proximityRange: joi.number().min(0).max(1000),
328
356
  preferredLanguage: joi.string().valid('en', 'fr', 'ar').optional(),
357
+ currency: joi.string().optional(),
329
358
  });
330
359
 
331
360
  exports.updateSchemaValidation = createValidationMiddleware(updateSchema, (req) => {
@@ -490,6 +519,7 @@ const updateProductSchema = joi.object({
490
519
  policy: policySchema,
491
520
  discountType: joi.string(),
492
521
  discountExpiration: joi.string(),
522
+ confirmed: joi.boolean().optional(),
493
523
  });
494
524
 
495
525
  exports.updateProductSchemaValidation = createValidationMiddleware(updateProductSchema, (req) => {
@@ -517,6 +547,7 @@ const createProductSchema = joi.object({
517
547
  storeId: joi.string().required(),
518
548
  variants: joi.array().items(createVariantSchema),
519
549
  policy: policySchema,
550
+ confirmed: joi.boolean().optional(),
520
551
  });
521
552
 
522
553
  exports.createProductSchemaValidation = createValidationMiddleware(createProductSchema, (req) => {
@@ -581,11 +612,87 @@ const schemaStore = joi.object({
581
612
  storeRayons: joi.string().allow('').allow(null),
582
613
  template: joi.string(),
583
614
  registrationNumber: joi.string(),
615
+ confirmed: joi.boolean().optional(),
616
+ physicalMerchantInfo: joi
617
+ .object({
618
+ approximateSurface: joi.number().allow(null),
619
+ shopPhotos: joi.array().items(joi.string()).allow(null),
620
+ })
621
+ .allow(null)
622
+ .optional(),
623
+ mobileMerchantInfo: joi
624
+ .object({
625
+ coveredZones: joi
626
+ .array()
627
+ .items(
628
+ joi.object({
629
+ city: joi.string().allow('').allow(null),
630
+ region: joi.string().allow('').allow(null),
631
+ latitude: joi.number().allow(null),
632
+ longitude: joi.number().allow(null),
633
+ })
634
+ )
635
+ .allow(null),
636
+ realTimePosition: joi.boolean().allow(null),
637
+ marketCalendar: joi
638
+ .array()
639
+ .items(
640
+ joi.object({
641
+ date: joi.string().allow('').allow(null),
642
+ location: joi.string().allow('').allow(null),
643
+ marketName: joi.string().allow('').allow(null),
644
+ })
645
+ )
646
+ .allow(null),
647
+ standPhoto: joi.string().allow('').allow(null),
648
+ visibleName: joi.string().allow('').allow(null),
649
+ })
650
+ .allow(null)
651
+ .optional(),
652
+ producerInfo: joi
653
+ .object({
654
+ productionType: joi.string().allow('').allow(null),
655
+ productionMethods: joi.array().items(joi.string()).allow(null),
656
+ visitPossible: joi.boolean().allow(null),
657
+ labels: joi
658
+ .array()
659
+ .items(
660
+ joi.object({
661
+ title: joi.string().allow('').allow(null),
662
+ link: joi.string().allow('').allow(null),
663
+ })
664
+ )
665
+ .allow(null),
666
+ directSale: joi.boolean().allow(null),
667
+ saleLocations: joi
668
+ .array()
669
+ .items(
670
+ joi.object({
671
+ name: joi.string().allow('').allow(null),
672
+ latitude: joi.number().allow(null),
673
+ longitude: joi.number().allow(null),
674
+ })
675
+ )
676
+ .allow(null),
677
+ deliveryScope: joi.string().valid('local', 'national').allow(null),
678
+ availableQuantities: joi.string().valid('small_series', 'volume', 'both').allow(null),
679
+ })
680
+ .allow(null)
681
+ .optional(),
682
+ eMerchantInfo: joi
683
+ .object({
684
+ websiteUrl: joi.string().allow('').allow(null),
685
+ platform: joi.string().allow('').allow(null),
686
+ onlineShopName: joi.string().allow('').allow(null),
687
+ approximateProductCount: joi.number().allow(null),
688
+ })
689
+ .allow(null)
690
+ .optional(),
584
691
  });
585
692
 
586
693
  exports.schemaStoreValidation = (req, res, next) => {
587
694
  console.log('Start store validation');
588
- parseJsonFields(req, ['location', 'address', 'policy', 'workingTime']);
695
+ parseJsonFields(req, ['location', 'address', 'policy', 'workingTime', 'physicalMerchantInfo', 'mobileMerchantInfo', 'producerInfo', 'eMerchantInfo']);
589
696
  console.log('Parsed workingTime:', req.body.workingTime);
590
697
 
591
698
  const { error } = schemaStore.validate(req.body);
@@ -614,10 +721,86 @@ const schemaUpdateStore = joi.object({
614
721
  storeRayons: joi.string().allow('').allow(null),
615
722
  template: joi.string(),
616
723
  registrationNumber: joi.string(),
724
+ confirmed: joi.boolean().optional(),
725
+ physicalMerchantInfo: joi
726
+ .object({
727
+ approximateSurface: joi.number().allow(null),
728
+ shopPhotos: joi.array().items(joi.string()).allow(null),
729
+ })
730
+ .allow(null)
731
+ .optional(),
732
+ mobileMerchantInfo: joi
733
+ .object({
734
+ coveredZones: joi
735
+ .array()
736
+ .items(
737
+ joi.object({
738
+ city: joi.string().allow('').allow(null),
739
+ region: joi.string().allow('').allow(null),
740
+ latitude: joi.number().allow(null),
741
+ longitude: joi.number().allow(null),
742
+ })
743
+ )
744
+ .allow(null),
745
+ realTimePosition: joi.boolean().allow(null),
746
+ marketCalendar: joi
747
+ .array()
748
+ .items(
749
+ joi.object({
750
+ date: joi.string().allow('').allow(null),
751
+ location: joi.string().allow('').allow(null),
752
+ marketName: joi.string().allow('').allow(null),
753
+ })
754
+ )
755
+ .allow(null),
756
+ standPhoto: joi.string().allow('').allow(null),
757
+ visibleName: joi.string().allow('').allow(null),
758
+ })
759
+ .allow(null)
760
+ .optional(),
761
+ producerInfo: joi
762
+ .object({
763
+ productionType: joi.string().allow('').allow(null),
764
+ productionMethods: joi.array().items(joi.string()).allow(null),
765
+ visitPossible: joi.boolean().allow(null),
766
+ labels: joi
767
+ .array()
768
+ .items(
769
+ joi.object({
770
+ title: joi.string().allow('').allow(null),
771
+ link: joi.string().allow('').allow(null),
772
+ })
773
+ )
774
+ .allow(null),
775
+ directSale: joi.boolean().allow(null),
776
+ saleLocations: joi
777
+ .array()
778
+ .items(
779
+ joi.object({
780
+ name: joi.string().allow('').allow(null),
781
+ latitude: joi.number().allow(null),
782
+ longitude: joi.number().allow(null),
783
+ })
784
+ )
785
+ .allow(null),
786
+ deliveryScope: joi.string().valid('local', 'national').allow(null),
787
+ availableQuantities: joi.string().valid('small_series', 'volume', 'both').allow(null),
788
+ })
789
+ .allow(null)
790
+ .optional(),
791
+ eMerchantInfo: joi
792
+ .object({
793
+ websiteUrl: joi.string().allow('').allow(null),
794
+ platform: joi.string().allow('').allow(null),
795
+ onlineShopName: joi.string().allow('').allow(null),
796
+ approximateProductCount: joi.number().allow(null),
797
+ })
798
+ .allow(null)
799
+ .optional(),
617
800
  });
618
801
 
619
802
  exports.schemaUpdateStoreValidation = (req, res, next) => {
620
- parseJsonFields(req, ['location', 'address', 'policy', 'workingTime']);
803
+ parseJsonFields(req, ['location', 'address', 'policy', 'workingTime', 'physicalMerchantInfo', 'mobileMerchantInfo', 'producerInfo', 'eMerchantInfo']);
621
804
  console.log('Parsed workingTime:', req.body.workingTime);
622
805
 
623
806
  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.16",
3
+ "version": "1.4.0",
4
4
  "description": "A library of Joi-based validation middlewares for Express.js",
5
5
  "main": "index.js",
6
6
  "license": "MIT",