@evergis/common 1.0.4-alpha.1 → 1.0.4-alpha.2
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/dist/classification/ClientStyleValidator/ClientStyleValidator.d.ts +3 -0
- package/dist/common.esm.js +119 -241
- package/dist/common.esm.js.map +1 -1
- package/dist/index.js +119 -241
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -11,9 +11,12 @@ export declare class ClientStyleValidator {
|
|
|
11
11
|
private validateSupportedMatchExpression;
|
|
12
12
|
private validateSupportedCaseExpression;
|
|
13
13
|
private validateSupportedStepExpression;
|
|
14
|
+
private validateInterpolateInputs;
|
|
15
|
+
private validateZoomInterpolateConsistency;
|
|
14
16
|
private validateLinearZoomInterpolate;
|
|
15
17
|
private validateExponentialZoomInterpolate;
|
|
16
18
|
private validateCubicBezierZoomInterpolate;
|
|
19
|
+
private validateDataInterpolateConsistency;
|
|
17
20
|
private validateLinearDataInterpolate;
|
|
18
21
|
private validateExponentialDataInterpolate;
|
|
19
22
|
private validateCubicBezierDataInterpolate;
|
package/dist/common.esm.js
CHANGED
|
@@ -369,7 +369,7 @@ class ClientStyleValidator {
|
|
|
369
369
|
errors: [
|
|
370
370
|
{
|
|
371
371
|
path: `item[${noPaintItemIndex}]`,
|
|
372
|
-
message: "The `paint` prop is
|
|
372
|
+
message: "The `paint` prop is required",
|
|
373
373
|
},
|
|
374
374
|
],
|
|
375
375
|
};
|
|
@@ -404,9 +404,9 @@ class ClientStyleValidator {
|
|
|
404
404
|
.every(e => typeof e === "string"));
|
|
405
405
|
}
|
|
406
406
|
isZoomInterpolate(value) {
|
|
407
|
-
return Array.isArray(value) && value[0] === "interpolate" &&
|
|
407
|
+
return Array.isArray(value) && value[0] === "interpolate" && isEqual(value[2], ["zoom"]);
|
|
408
408
|
}
|
|
409
|
-
validateSupportedConcatExpression(path, key, value
|
|
409
|
+
validateSupportedConcatExpression(path, key, value) {
|
|
410
410
|
const errorsCount = this.errors.length;
|
|
411
411
|
if (key !== "text-field") {
|
|
412
412
|
this.errors.push({
|
|
@@ -433,11 +433,9 @@ class ClientStyleValidator {
|
|
|
433
433
|
});
|
|
434
434
|
}
|
|
435
435
|
}
|
|
436
|
-
|
|
437
|
-
return this.errors.length === errorsCount;
|
|
438
|
-
}
|
|
436
|
+
return this.errors.length === errorsCount;
|
|
439
437
|
}
|
|
440
|
-
validateSupportedMatchExpression(path, key, value
|
|
438
|
+
validateSupportedMatchExpression(path, key, value) {
|
|
441
439
|
const errorsCount = this.errors.length;
|
|
442
440
|
if (!this.getSpecPropValueOptions(key)?.dataExpressionSupport) {
|
|
443
441
|
this.errors.push({
|
|
@@ -463,7 +461,7 @@ class ClientStyleValidator {
|
|
|
463
461
|
.slice(2)
|
|
464
462
|
.every(e => typeof e === "number" ||
|
|
465
463
|
typeof e === "string" ||
|
|
466
|
-
(key === "text-field" && this.validateSupportedConcatExpression(path, key, e
|
|
464
|
+
(key === "text-field" && this.validateSupportedConcatExpression(path, key, e)));
|
|
467
465
|
if (!result) {
|
|
468
466
|
this.errors.push({
|
|
469
467
|
path: `${path}.${key}`,
|
|
@@ -471,11 +469,9 @@ class ClientStyleValidator {
|
|
|
471
469
|
});
|
|
472
470
|
}
|
|
473
471
|
}
|
|
474
|
-
|
|
475
|
-
return this.errors.length === errorsCount;
|
|
476
|
-
}
|
|
472
|
+
return this.errors.length === errorsCount;
|
|
477
473
|
}
|
|
478
|
-
validateSupportedCaseExpression(path, key, value
|
|
474
|
+
validateSupportedCaseExpression(path, key, value) {
|
|
479
475
|
const errorsCount = this.errors.length;
|
|
480
476
|
if (!this.getSpecPropValueOptions(key)?.dataExpressionSupport) {
|
|
481
477
|
this.errors.push({
|
|
@@ -512,10 +508,10 @@ class ClientStyleValidator {
|
|
|
512
508
|
.filter((_, i) => i % 2 !== 0)
|
|
513
509
|
.every(e => typeof e === "number" ||
|
|
514
510
|
typeof e === "string" ||
|
|
515
|
-
(key === "text-field" && this.validateSupportedConcatExpression(path, key, e
|
|
511
|
+
(key === "text-field" && this.validateSupportedConcatExpression(path, key, e))) &&
|
|
516
512
|
(typeof value[value.slice(1).length - 1] === "number" ||
|
|
517
513
|
typeof value[value.slice(1).length - 1] === "string" ||
|
|
518
|
-
(key === "text-field" && this.validateSupportedConcatExpression(path, key, value
|
|
514
|
+
(key === "text-field" && this.validateSupportedConcatExpression(path, key, value)));
|
|
519
515
|
if (!result) {
|
|
520
516
|
this.errors.push({
|
|
521
517
|
path: `${path}.${key}`,
|
|
@@ -523,11 +519,9 @@ class ClientStyleValidator {
|
|
|
523
519
|
});
|
|
524
520
|
}
|
|
525
521
|
}
|
|
526
|
-
|
|
527
|
-
return this.errors.length === errorsCount;
|
|
528
|
-
}
|
|
522
|
+
return this.errors.length === errorsCount;
|
|
529
523
|
}
|
|
530
|
-
validateSupportedStepExpression(path, key, value
|
|
524
|
+
validateSupportedStepExpression(path, key, value) {
|
|
531
525
|
const errorsCount = this.errors.length;
|
|
532
526
|
if (!this.getSpecPropValueOptions(key)?.dataExpressionSupport) {
|
|
533
527
|
this.errors.push({
|
|
@@ -554,7 +548,7 @@ class ClientStyleValidator {
|
|
|
554
548
|
.filter((_, i) => i % 2 === 0)
|
|
555
549
|
.every(e => typeof e === "number" ||
|
|
556
550
|
typeof e === "string" ||
|
|
557
|
-
(key === "text-field" && this.validateSupportedConcatExpression(path, key, e
|
|
551
|
+
(key === "text-field" && this.validateSupportedConcatExpression(path, key, e))) &&
|
|
558
552
|
value
|
|
559
553
|
.slice(2)
|
|
560
554
|
.filter((_, i) => i % 2 !== 0)
|
|
@@ -566,251 +560,138 @@ class ClientStyleValidator {
|
|
|
566
560
|
});
|
|
567
561
|
}
|
|
568
562
|
}
|
|
569
|
-
|
|
570
|
-
return this.errors.length === errorsCount;
|
|
571
|
-
}
|
|
563
|
+
return this.errors.length === errorsCount;
|
|
572
564
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
565
|
+
validateInterpolateInputs(value) {
|
|
566
|
+
return value
|
|
567
|
+
.slice(3)
|
|
568
|
+
.filter((_, i) => i % 2 === 0)
|
|
569
|
+
.every(e => typeof e === "number");
|
|
570
|
+
}
|
|
571
|
+
validateZoomInterpolateConsistency(path, key, value) {
|
|
572
|
+
return (this.validateInterpolateInputs(value) &&
|
|
578
573
|
isEqual(value[2], ["zoom"]) &&
|
|
579
574
|
value.length % 2 !== 0 &&
|
|
580
575
|
value.length > 4 &&
|
|
581
|
-
value
|
|
582
|
-
.slice(3)
|
|
583
|
-
.filter((_, i) => i % 2 === 0)
|
|
584
|
-
.every(e => typeof e === "number") &&
|
|
585
576
|
value
|
|
586
577
|
.slice(3)
|
|
587
578
|
.filter((_, i) => i % 2 !== 0)
|
|
588
579
|
.every(e => {
|
|
589
580
|
return (typeof e === "number" ||
|
|
590
581
|
typeof e === "string" ||
|
|
591
|
-
this.validateSupportedExpression(path, key, e, true
|
|
592
|
-
(key === "text-field" && this.validateSupportedConcatExpression(path, key, e
|
|
582
|
+
this.validateSupportedExpression(path, key, e, true) ||
|
|
583
|
+
(key === "text-field" && this.validateSupportedConcatExpression(path, key, e)));
|
|
593
584
|
}));
|
|
594
|
-
if (!result) {
|
|
595
|
-
this.errors.push({
|
|
596
|
-
path: `${path}.${key}`,
|
|
597
|
-
message: "Invalid expression",
|
|
598
|
-
});
|
|
599
|
-
}
|
|
600
|
-
if (returnStatus) {
|
|
601
|
-
return this.errors.length === errorsCount;
|
|
602
|
-
}
|
|
603
585
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
586
|
+
validateLinearZoomInterpolate(path, key, value) {
|
|
587
|
+
return (this.getSpecPropValueOptions(key)?.interpolateExpressionSupport &&
|
|
588
|
+
isEqual(value[0], "interpolate") &&
|
|
589
|
+
isEqual(value[1], ["linear"]) &&
|
|
590
|
+
this.validateZoomInterpolateConsistency(path, key, value));
|
|
591
|
+
}
|
|
592
|
+
validateExponentialZoomInterpolate(path, key, value) {
|
|
593
|
+
return (this.getSpecPropValueOptions(key)?.interpolateExpressionSupport &&
|
|
607
594
|
isEqual(value[0], "interpolate") &&
|
|
608
595
|
Array.isArray(value[1]) &&
|
|
609
596
|
value[1].length === 2 &&
|
|
610
597
|
value[1][0] === "exponential" &&
|
|
611
598
|
typeof value[1][1] === "number" &&
|
|
612
|
-
|
|
613
|
-
value.length % 2 !== 0 &&
|
|
614
|
-
value.length > 4 &&
|
|
615
|
-
value
|
|
616
|
-
.slice(3)
|
|
617
|
-
.filter((_, i) => i % 2 === 0)
|
|
618
|
-
.every(e => typeof e === "number") &&
|
|
619
|
-
value
|
|
620
|
-
.slice(3)
|
|
621
|
-
.filter((_, i) => i % 2 !== 0)
|
|
622
|
-
.every(e => {
|
|
623
|
-
return (typeof e === "number" ||
|
|
624
|
-
typeof e === "string" ||
|
|
625
|
-
this.validateSupportedExpression(path, key, e, true, true) ||
|
|
626
|
-
(key === "text-field" && this.validateSupportedConcatExpression(path, key, e, true)));
|
|
627
|
-
}));
|
|
628
|
-
if (!result) {
|
|
629
|
-
this.errors.push({
|
|
630
|
-
path: `${path}.${key}`,
|
|
631
|
-
message: "Invalid expression",
|
|
632
|
-
});
|
|
633
|
-
}
|
|
634
|
-
if (returnStatus) {
|
|
635
|
-
return this.errors.length === errorsCount;
|
|
636
|
-
}
|
|
599
|
+
this.validateZoomInterpolateConsistency(path, key, value));
|
|
637
600
|
}
|
|
638
|
-
validateCubicBezierZoomInterpolate(path, key, value
|
|
639
|
-
|
|
640
|
-
const result = (this.getSpecPropValueOptions(key)?.interpolateExpressionSupport &&
|
|
601
|
+
validateCubicBezierZoomInterpolate(path, key, value) {
|
|
602
|
+
return (this.getSpecPropValueOptions(key)?.interpolateExpressionSupport &&
|
|
641
603
|
isEqual(value[0], "interpolate") &&
|
|
642
604
|
Array.isArray(value[1]) &&
|
|
643
605
|
value[1].length === 5 &&
|
|
644
606
|
value[1][0] === "cubic-bezier" &&
|
|
645
607
|
value[1].slice(1).every(e => typeof e === "number") &&
|
|
646
|
-
|
|
647
|
-
value.length % 2 !== 0 &&
|
|
648
|
-
value.length > 4 &&
|
|
649
|
-
value
|
|
650
|
-
.slice(3)
|
|
651
|
-
.filter((_, i) => i % 2 === 0)
|
|
652
|
-
.every(e => typeof e === "number") &&
|
|
653
|
-
value
|
|
654
|
-
.slice(3)
|
|
655
|
-
.filter((_, i) => i % 2 !== 0)
|
|
656
|
-
.every(e => {
|
|
657
|
-
return (typeof e === "number" ||
|
|
658
|
-
typeof e === "string" ||
|
|
659
|
-
this.validateSupportedExpression(path, key, e, true, true) ||
|
|
660
|
-
(key === "text-field" && this.validateSupportedConcatExpression(path, key, e, true)));
|
|
661
|
-
}));
|
|
662
|
-
if (!result) {
|
|
663
|
-
this.errors.push({
|
|
664
|
-
path: `${path}.${key}`,
|
|
665
|
-
message: "Invalid expression",
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
if (returnStatus) {
|
|
669
|
-
return this.errors.length === errorsCount;
|
|
670
|
-
}
|
|
608
|
+
this.validateZoomInterpolateConsistency(path, key, value));
|
|
671
609
|
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
const result = (this.getSpecPropValueOptions(key)?.dataExpressionSupport &&
|
|
675
|
-
isEqual(value[0], "interpolate") &&
|
|
676
|
-
isEqual(value[1], ["linear"]) &&
|
|
610
|
+
validateDataInterpolateConsistency(path, key, value) {
|
|
611
|
+
return (this.validateInterpolateInputs(value) &&
|
|
677
612
|
Array.isArray(value[2]) &&
|
|
678
613
|
value[2].length === 2 &&
|
|
679
614
|
value[2][0] === "get" &&
|
|
680
615
|
typeof value[2][1] === "string" &&
|
|
681
616
|
value.length % 2 !== 0 &&
|
|
682
617
|
value.length > 4 &&
|
|
683
|
-
value
|
|
684
|
-
.slice(3)
|
|
685
|
-
.filter((_, i) => i % 2 === 0)
|
|
686
|
-
.every(e => typeof e === "number") &&
|
|
687
618
|
value
|
|
688
619
|
.slice(3)
|
|
689
620
|
.filter((_, i) => i % 2 !== 0)
|
|
690
621
|
.every(e => typeof e === "number" ||
|
|
691
622
|
typeof e === "string" ||
|
|
692
|
-
(key === "text-field" && this.validateSupportedConcatExpression(path, key, e
|
|
693
|
-
if (!result) {
|
|
694
|
-
this.errors.push({
|
|
695
|
-
path: `${path}.${key}`,
|
|
696
|
-
message: "Invalid expression",
|
|
697
|
-
});
|
|
698
|
-
}
|
|
699
|
-
if (returnStatus) {
|
|
700
|
-
return this.errors.length === errorsCount;
|
|
701
|
-
}
|
|
623
|
+
(key === "text-field" && this.validateSupportedConcatExpression(path, key, e))));
|
|
702
624
|
}
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
625
|
+
validateLinearDataInterpolate(path, key, value) {
|
|
626
|
+
return (this.getSpecPropValueOptions(key)?.dataExpressionSupport &&
|
|
627
|
+
isEqual(value[0], "interpolate") &&
|
|
628
|
+
isEqual(value[1], ["linear"]) &&
|
|
629
|
+
this.validateDataInterpolateConsistency(path, key, value));
|
|
630
|
+
}
|
|
631
|
+
validateExponentialDataInterpolate(path, key, value) {
|
|
632
|
+
return (this.getSpecPropValueOptions(key)?.dataExpressionSupport &&
|
|
706
633
|
isEqual(value[0], "interpolate") &&
|
|
707
634
|
Array.isArray(value[1]) &&
|
|
708
635
|
value[1].length === 2 &&
|
|
709
636
|
value[1][0] === "exponential" &&
|
|
710
637
|
typeof value[1][1] === "number" &&
|
|
711
|
-
|
|
712
|
-
value[2].length === 2 &&
|
|
713
|
-
value[2][0] === "get" &&
|
|
714
|
-
typeof value[2][1] === "string" &&
|
|
715
|
-
value.length % 2 !== 0 &&
|
|
716
|
-
value.length > 4 &&
|
|
717
|
-
value
|
|
718
|
-
.slice(3)
|
|
719
|
-
.filter((_, i) => i % 2 === 0)
|
|
720
|
-
.every(e => typeof e === "number") &&
|
|
721
|
-
value
|
|
722
|
-
.slice(3)
|
|
723
|
-
.filter((_, i) => i % 2 !== 0)
|
|
724
|
-
.every(e => typeof e === "number" ||
|
|
725
|
-
typeof e === "string" ||
|
|
726
|
-
(key === "text-field" && this.validateSupportedConcatExpression(path, key, e, true))));
|
|
727
|
-
if (!result) {
|
|
728
|
-
this.errors.push({
|
|
729
|
-
path: `${path}.${key}`,
|
|
730
|
-
message: "Invalid expression",
|
|
731
|
-
});
|
|
732
|
-
}
|
|
733
|
-
if (returnStatus) {
|
|
734
|
-
return this.errors.length === errorsCount;
|
|
735
|
-
}
|
|
638
|
+
this.validateDataInterpolateConsistency(path, key, value));
|
|
736
639
|
}
|
|
737
|
-
validateCubicBezierDataInterpolate(path, key, value
|
|
738
|
-
|
|
739
|
-
const result = (this.getSpecPropValueOptions(key)?.dataExpressionSupport &&
|
|
640
|
+
validateCubicBezierDataInterpolate(path, key, value) {
|
|
641
|
+
return (this.getSpecPropValueOptions(key)?.dataExpressionSupport &&
|
|
740
642
|
isEqual(value[0], "interpolate") &&
|
|
741
643
|
Array.isArray(value[1]) &&
|
|
742
644
|
value[1].length === 5 &&
|
|
743
645
|
value[1][0] === "cubic-bezier" &&
|
|
744
646
|
value[1].slice(1).every(e => typeof e === "number") &&
|
|
745
|
-
|
|
746
|
-
value[2].length === 2 &&
|
|
747
|
-
value[2][0] === "get" &&
|
|
748
|
-
typeof value[2][1] === "string" &&
|
|
749
|
-
value.length % 2 !== 0 &&
|
|
750
|
-
value.length > 4 &&
|
|
751
|
-
value
|
|
752
|
-
.slice(3)
|
|
753
|
-
.filter((_, i) => i % 2 === 0)
|
|
754
|
-
.every(e => typeof e === "number") &&
|
|
755
|
-
value
|
|
756
|
-
.slice(3)
|
|
757
|
-
.filter((_, i) => i % 2 !== 0)
|
|
758
|
-
.every(e => typeof e === "number" ||
|
|
759
|
-
typeof e === "string" ||
|
|
760
|
-
(key === "text-field" && this.validateSupportedConcatExpression(path, key, e, true))));
|
|
761
|
-
if (!result) {
|
|
762
|
-
this.errors.push({
|
|
763
|
-
path: `${path}.${key}`,
|
|
764
|
-
message: "Invalid expression",
|
|
765
|
-
});
|
|
766
|
-
}
|
|
767
|
-
if (returnStatus) {
|
|
768
|
-
return this.errors.length === errorsCount;
|
|
769
|
-
}
|
|
647
|
+
this.validateDataInterpolateConsistency(path, key, value));
|
|
770
648
|
}
|
|
771
649
|
validateZoomInterpolate(path, key, value) {
|
|
772
650
|
const isAllowedInterpolate = this.getSpecPropValueOptions(key)?.interpolateExpressionSupport && isEqual(value[0], "interpolate");
|
|
773
|
-
if (isAllowedInterpolate
|
|
651
|
+
if (!isAllowedInterpolate) {
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
if (isEqual(value[1], ["linear"])) {
|
|
774
655
|
this.validateLinearZoomInterpolate(path, key, value);
|
|
775
656
|
}
|
|
776
|
-
|
|
657
|
+
if (isEqual(value[1], ["exponential"])) {
|
|
777
658
|
this.validateExponentialZoomInterpolate(path, key, value);
|
|
778
659
|
}
|
|
779
|
-
|
|
660
|
+
if (isEqual(value[1], ["cubic-bezier"])) {
|
|
780
661
|
this.validateCubicBezierZoomInterpolate(path, key, value);
|
|
781
662
|
}
|
|
782
663
|
}
|
|
783
664
|
validateDataInterpolate(path, key, value) {
|
|
784
665
|
const isAllowedInterpolate = this.getSpecPropValueOptions(key)?.dataExpressionSupport && isEqual(value[0], "interpolate");
|
|
785
|
-
if (isAllowedInterpolate
|
|
666
|
+
if (!isAllowedInterpolate) {
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
if (isEqual(value[1], ["linear"])) {
|
|
786
670
|
this.validateLinearDataInterpolate(path, key, value);
|
|
787
671
|
}
|
|
788
|
-
|
|
672
|
+
if (isEqual(value[1], ["exponential"])) {
|
|
789
673
|
this.validateExponentialDataInterpolate(path, key, value);
|
|
790
674
|
}
|
|
791
|
-
|
|
675
|
+
if (isEqual(value[1], ["cubic-bezier"])) {
|
|
792
676
|
this.validateCubicBezierDataInterpolate(path, key, value);
|
|
793
677
|
}
|
|
794
678
|
}
|
|
795
|
-
validateSupportedInterpolateExpression(path, key, value, excludeZoomInterpolate
|
|
679
|
+
validateSupportedInterpolateExpression(path, key, value, excludeZoomInterpolate) {
|
|
796
680
|
const errorsCount = this.errors.length;
|
|
681
|
+
const propValueOptions = this.getSpecPropValueOptions(key);
|
|
797
682
|
if (!expression.isExpression(value)) {
|
|
798
683
|
this.errors.push({
|
|
799
684
|
path: `${path}.${key}`,
|
|
800
685
|
message: "Not an expression",
|
|
801
686
|
});
|
|
802
687
|
}
|
|
803
|
-
else if (key === "heatmap-color") {
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
message: "Invalid color value",
|
|
809
|
-
});
|
|
810
|
-
}
|
|
688
|
+
else if (key === "heatmap-color" && !this.isHeatmapColorValid(value)) {
|
|
689
|
+
this.errors.push({
|
|
690
|
+
path: `${path}.${key}`,
|
|
691
|
+
message: "Invalid color value",
|
|
692
|
+
});
|
|
811
693
|
}
|
|
812
|
-
else if (!
|
|
813
|
-
!this.getSpecPropValueOptions(key)?.dataExpressionSupport) {
|
|
694
|
+
else if (!propValueOptions?.interpolateExpressionSupport && !propValueOptions?.dataExpressionSupport) {
|
|
814
695
|
this.errors.push({
|
|
815
696
|
path: `${path}.${key}`,
|
|
816
697
|
message: "Interpolate not supported",
|
|
@@ -822,11 +703,9 @@ class ClientStyleValidator {
|
|
|
822
703
|
else {
|
|
823
704
|
this.validateDataInterpolate(path, key, value);
|
|
824
705
|
}
|
|
825
|
-
|
|
826
|
-
return this.errors.length === errorsCount;
|
|
827
|
-
}
|
|
706
|
+
return this.errors.length === errorsCount;
|
|
828
707
|
}
|
|
829
|
-
validateSupportedExpression(path, key, value, excludeZoomInterpolate
|
|
708
|
+
validateSupportedExpression(path, key, value, excludeZoomInterpolate) {
|
|
830
709
|
const errorsCount = this.errors.length;
|
|
831
710
|
if (!expression.isExpression(value)) {
|
|
832
711
|
this.errors.push({
|
|
@@ -836,8 +715,7 @@ class ClientStyleValidator {
|
|
|
836
715
|
}
|
|
837
716
|
else {
|
|
838
717
|
const expressionType = value[0];
|
|
839
|
-
if (typeof expressionType !== "string" ||
|
|
840
|
-
!["match", "case", "step", "interpolate", "concat"].includes(expressionType)) {
|
|
718
|
+
if (typeof expressionType !== "string" || !["match", "case", "step", "interpolate", "concat"].includes(expressionType)) {
|
|
841
719
|
this.errors.push({
|
|
842
720
|
path: `${path}.${key}`,
|
|
843
721
|
message: "Expression type not supported (supported types: \"match\", \"case\", \"step\", \"interpolate\", \"concat\")",
|
|
@@ -863,11 +741,9 @@ class ClientStyleValidator {
|
|
|
863
741
|
}
|
|
864
742
|
}
|
|
865
743
|
}
|
|
866
|
-
|
|
867
|
-
return this.errors.length === errorsCount;
|
|
868
|
-
}
|
|
744
|
+
return this.errors.length === errorsCount;
|
|
869
745
|
}
|
|
870
|
-
validateTransitionValue(path, key, value
|
|
746
|
+
validateTransitionValue(path, key, value) {
|
|
871
747
|
const errorsCount = this.errors.length;
|
|
872
748
|
const propValueOptions = this.getSpecPropValueOptions(key.replace(/-transition$/, ""));
|
|
873
749
|
if (propValueOptions && propValueOptions.transitionable === false) {
|
|
@@ -887,60 +763,62 @@ class ClientStyleValidator {
|
|
|
887
763
|
});
|
|
888
764
|
}
|
|
889
765
|
}
|
|
890
|
-
|
|
891
|
-
return this.errors.length === errorsCount;
|
|
892
|
-
}
|
|
766
|
+
return this.errors.length === errorsCount;
|
|
893
767
|
}
|
|
894
768
|
validateSpecPropValue(path, key, value) {
|
|
895
769
|
if (key.endsWith("-transition")) {
|
|
896
770
|
this.validateTransitionValue(path, key, value);
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
const propValueOptions = this.getSpecPropValueOptions(key);
|
|
774
|
+
const isExpression = expression.isExpression(value);
|
|
775
|
+
if (!propValueOptions) {
|
|
776
|
+
const result = (typeof value === "string" ||
|
|
777
|
+
typeof value === "number" ||
|
|
778
|
+
typeof value === "boolean" ||
|
|
779
|
+
(Array.isArray(value) && value.every(item => typeof item === "number")) ||
|
|
780
|
+
(Array.isArray(value) && value.every(item => typeof item === "string")) ||
|
|
781
|
+
isExpression);
|
|
782
|
+
if (!result) {
|
|
783
|
+
this.errors.push({
|
|
784
|
+
path: `${path}.${key}`,
|
|
785
|
+
message: "Invalid value",
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
return;
|
|
897
789
|
}
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
typeof value === "number" ||
|
|
903
|
-
typeof value === "boolean" ||
|
|
904
|
-
(Array.isArray(value) && value.every(item => typeof item === "number")) ||
|
|
905
|
-
(Array.isArray(value) && value.every(item => typeof item === "string")) ||
|
|
906
|
-
expression.isExpression(value));
|
|
790
|
+
if (propValueOptions.arrayValue) {
|
|
791
|
+
if (!propValueOptions.arrayOnly) {
|
|
792
|
+
const result = (typeof value === propValueOptions.valueTypeAllowed ||
|
|
793
|
+
(Array.isArray(value) && value.every(item => typeof item === propValueOptions.valueTypeAllowed)));
|
|
907
794
|
if (!result) {
|
|
908
795
|
this.errors.push({
|
|
909
796
|
path: `${path}.${key}`,
|
|
910
|
-
message:
|
|
797
|
+
message: `Only values of type ${propValueOptions.valueTypeAllowed} allowed`,
|
|
911
798
|
});
|
|
912
799
|
}
|
|
913
800
|
}
|
|
914
|
-
else
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
message: `Only values of type ${propValueOptions.valueTypeAllowed} allowed`,
|
|
922
|
-
});
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
else {
|
|
926
|
-
const result = Array.isArray(value) && value.every(item => typeof item === propValueOptions.valueTypeAllowed);
|
|
927
|
-
if (!result) {
|
|
928
|
-
this.errors.push({
|
|
929
|
-
path: `${path}.${key}`,
|
|
930
|
-
message: `Only array of values of type ${propValueOptions.valueTypeAllowed} allowed`,
|
|
931
|
-
});
|
|
932
|
-
}
|
|
801
|
+
else {
|
|
802
|
+
const result = Array.isArray(value) && value.every(item => typeof item === propValueOptions.valueTypeAllowed);
|
|
803
|
+
if (!result) {
|
|
804
|
+
this.errors.push({
|
|
805
|
+
path: `${path}.${key}`,
|
|
806
|
+
message: `Only array of values of type ${propValueOptions.valueTypeAllowed} allowed`,
|
|
807
|
+
});
|
|
933
808
|
}
|
|
934
809
|
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
812
|
+
if (isExpression) {
|
|
813
|
+
this.validateSupportedExpression(path, key, value);
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
if (typeof value !== propValueOptions.valueTypeAllowed) {
|
|
817
|
+
this.errors.push({
|
|
818
|
+
path: `${path}.${key}`,
|
|
819
|
+
message: "Invalid value type",
|
|
820
|
+
});
|
|
821
|
+
return;
|
|
944
822
|
}
|
|
945
823
|
}
|
|
946
824
|
}
|