data-validation-proximity 1.3.17 → 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 +183 -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({
@@ -492,6 +519,7 @@ const updateProductSchema = joi.object({
492
519
  policy: policySchema,
493
520
  discountType: joi.string(),
494
521
  discountExpiration: joi.string(),
522
+ confirmed: joi.boolean().optional(),
495
523
  });
496
524
 
497
525
  exports.updateProductSchemaValidation = createValidationMiddleware(updateProductSchema, (req) => {
@@ -519,6 +547,7 @@ const createProductSchema = joi.object({
519
547
  storeId: joi.string().required(),
520
548
  variants: joi.array().items(createVariantSchema),
521
549
  policy: policySchema,
550
+ confirmed: joi.boolean().optional(),
522
551
  });
523
552
 
524
553
  exports.createProductSchemaValidation = createValidationMiddleware(createProductSchema, (req) => {
@@ -583,11 +612,87 @@ const schemaStore = joi.object({
583
612
  storeRayons: joi.string().allow('').allow(null),
584
613
  template: joi.string(),
585
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(),
586
691
  });
587
692
 
588
693
  exports.schemaStoreValidation = (req, res, next) => {
589
694
  console.log('Start store validation');
590
- parseJsonFields(req, ['location', 'address', 'policy', 'workingTime']);
695
+ parseJsonFields(req, ['location', 'address', 'policy', 'workingTime', 'physicalMerchantInfo', 'mobileMerchantInfo', 'producerInfo', 'eMerchantInfo']);
591
696
  console.log('Parsed workingTime:', req.body.workingTime);
592
697
 
593
698
  const { error } = schemaStore.validate(req.body);
@@ -616,10 +721,86 @@ const schemaUpdateStore = joi.object({
616
721
  storeRayons: joi.string().allow('').allow(null),
617
722
  template: joi.string(),
618
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(),
619
800
  });
620
801
 
621
802
  exports.schemaUpdateStoreValidation = (req, res, next) => {
622
- parseJsonFields(req, ['location', 'address', 'policy', 'workingTime']);
803
+ parseJsonFields(req, ['location', 'address', 'policy', 'workingTime', 'physicalMerchantInfo', 'mobileMerchantInfo', 'producerInfo', 'eMerchantInfo']);
623
804
  console.log('Parsed workingTime:', req.body.workingTime);
624
805
 
625
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.17",
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",