joi 4.8.1 → 4.9.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.
- package/.c9/metadata/tab0 +1 -1
- package/.c9/metadata/workspace/.travis.yml +1 -0
- package/.c9/metadata/workspace/Makefile +1 -1
- package/.c9/metadata/workspace/README.md +1 -1
- package/.c9/metadata/workspace/lib/any.js +1 -0
- package/.c9/metadata/workspace/lib/binary.js +1 -0
- package/.c9/metadata/workspace/lib/boolean.js +1 -0
- package/.c9/metadata/workspace/lib/cast.js +1 -0
- package/.c9/metadata/workspace/lib/date.js +1 -1
- package/.c9/metadata/workspace/lib/function.js +1 -0
- package/.c9/metadata/workspace/lib/object.js +1 -0
- package/.c9/metadata/workspace/test/alternatives.js +1 -1
- package/.c9/metadata/workspace/test/array.js +1 -1
- package/.c9/metadata/workspace/test/index.js +1 -1
- package/.c9/metadata/workspace/test/ref.js +1 -1
- package/.travis.yml +1 -0
- package/Makefile +3 -3
- package/README.md +11 -0
- package/lib/language.js +2 -1
- package/lib/object.js +16 -0
- package/package.json +1 -1
- package/test/alternatives.js +5 -5
- package/test/any.js +10 -10
- package/test/array.js +11 -11
- package/test/binary.js +4 -4
- package/test/boolean.js +2 -2
- package/test/date.js +8 -8
- package/test/errors.js +7 -7
- package/test/index.js +67 -67
- package/test/number.js +6 -6
- package/test/object.js +107 -36
- package/test/ref.js +15 -15
- package/test/string.js +9 -9
package/test/index.js
CHANGED
|
@@ -40,7 +40,7 @@ describe('Joi', function () {
|
|
|
40
40
|
|
|
41
41
|
schema.validate(obj, function (err, value) {
|
|
42
42
|
|
|
43
|
-
expect(err).to.not.exist;
|
|
43
|
+
expect(err).to.not.exist();
|
|
44
44
|
done();
|
|
45
45
|
});
|
|
46
46
|
});
|
|
@@ -69,7 +69,7 @@ describe('Joi', function () {
|
|
|
69
69
|
|
|
70
70
|
Joi.string().validate(null, function (err, value) {
|
|
71
71
|
|
|
72
|
-
expect(err).to.exist;
|
|
72
|
+
expect(err).to.exist();
|
|
73
73
|
expect(err.annotate()).to.equal('{\n \u001b[41m\"value\"\u001b[0m\u001b[31m [1]: -- missing --\u001b[0m\n}\n\u001b[31m\n[1] value must be a string\u001b[0m');
|
|
74
74
|
done();
|
|
75
75
|
});
|
|
@@ -153,10 +153,10 @@ describe('Joi', function () {
|
|
|
153
153
|
|
|
154
154
|
Joi.compile(/^5$/).validate('5', function (err, value) {
|
|
155
155
|
|
|
156
|
-
expect(err).to.not.exist;
|
|
156
|
+
expect(err).to.not.exist();
|
|
157
157
|
Joi.compile(/.{2}/).validate('6', function (err, value) {
|
|
158
158
|
|
|
159
|
-
expect(err).to.exist;
|
|
159
|
+
expect(err).to.exist();
|
|
160
160
|
done();
|
|
161
161
|
});
|
|
162
162
|
});
|
|
@@ -405,7 +405,7 @@ describe('Joi', function () {
|
|
|
405
405
|
|
|
406
406
|
schema.validate({ auth: { mode: 'none' } }, function (err, value) {
|
|
407
407
|
|
|
408
|
-
expect(err).to.exist;
|
|
408
|
+
expect(err).to.exist();
|
|
409
409
|
expect(err.message).to.equal('mode must be one of required, optional, try, null. auth must be a string. auth must be a boolean');
|
|
410
410
|
|
|
411
411
|
Helper.validate(schema, [
|
|
@@ -435,7 +435,7 @@ describe('Joi', function () {
|
|
|
435
435
|
|
|
436
436
|
schema.validate({ auth: { mode: 'none' } }, function (err, value) {
|
|
437
437
|
|
|
438
|
-
expect(err).to.exist;
|
|
438
|
+
expect(err).to.exist();
|
|
439
439
|
expect(err.message).to.equal('mode must be one of required, optional, try, null. auth must be a string. auth must be a boolean');
|
|
440
440
|
|
|
441
441
|
Helper.validate(schema, [
|
|
@@ -527,7 +527,7 @@ describe('Joi', function () {
|
|
|
527
527
|
|
|
528
528
|
schema.validate(obj, function (err, value) {
|
|
529
529
|
|
|
530
|
-
expect(err).to.exist;
|
|
530
|
+
expect(err).to.exist();
|
|
531
531
|
expect(value.a).to.equal('5');
|
|
532
532
|
done();
|
|
533
533
|
});
|
|
@@ -543,7 +543,7 @@ describe('Joi', function () {
|
|
|
543
543
|
|
|
544
544
|
schema.validate(obj, function (err, value) {
|
|
545
545
|
|
|
546
|
-
expect(err).to.not.exist;
|
|
546
|
+
expect(err).to.not.exist();
|
|
547
547
|
expect(value.hasOwnProperty('a')).to.equal(false);
|
|
548
548
|
done();
|
|
549
549
|
});
|
|
@@ -568,7 +568,7 @@ describe('Joi', function () {
|
|
|
568
568
|
|
|
569
569
|
schema.validate({ username: 'bob' }, function (err, value) {
|
|
570
570
|
|
|
571
|
-
expect(err).to.exist;
|
|
571
|
+
expect(err).to.exist();
|
|
572
572
|
done();
|
|
573
573
|
});
|
|
574
574
|
});
|
|
@@ -577,10 +577,10 @@ describe('Joi', function () {
|
|
|
577
577
|
|
|
578
578
|
Joi.boolean().allow(null).validate(true, function (err, value) {
|
|
579
579
|
|
|
580
|
-
expect(err).to.be.null;
|
|
580
|
+
expect(err).to.be.null();
|
|
581
581
|
Joi.object().validate({ auth: { mode: 'try' } }, function (err, value) {
|
|
582
582
|
|
|
583
|
-
expect(err).to.be.null;
|
|
583
|
+
expect(err).to.be.null();
|
|
584
584
|
|
|
585
585
|
Joi.object().validate(true, function (err, value) {
|
|
586
586
|
|
|
@@ -592,10 +592,10 @@ describe('Joi', function () {
|
|
|
592
592
|
|
|
593
593
|
Joi.string().email().validate('test@test.com', function (err, value) {
|
|
594
594
|
|
|
595
|
-
expect(err).to.be.null;
|
|
595
|
+
expect(err).to.be.null();
|
|
596
596
|
Joi.object({ param: Joi.string().required() }).validate({ param: 'item' }, function (err, value) {
|
|
597
597
|
|
|
598
|
-
expect(err).to.be.null;
|
|
598
|
+
expect(err).to.be.null();
|
|
599
599
|
done();
|
|
600
600
|
});
|
|
601
601
|
});
|
|
@@ -614,7 +614,7 @@ describe('Joi', function () {
|
|
|
614
614
|
var input = { a: '5' };
|
|
615
615
|
schema.validate(input, function (err, value) {
|
|
616
616
|
|
|
617
|
-
expect(err).to.be.null;
|
|
617
|
+
expect(err).to.be.null();
|
|
618
618
|
expect(value.a).to.equal(5);
|
|
619
619
|
expect(input.a).to.equal('5');
|
|
620
620
|
done();
|
|
@@ -625,7 +625,7 @@ describe('Joi', function () {
|
|
|
625
625
|
|
|
626
626
|
Joi.object().validate({ foo: 'bar' }, function (err, value) {
|
|
627
627
|
|
|
628
|
-
expect(err).to.not.exist;
|
|
628
|
+
expect(err).to.not.exist();
|
|
629
629
|
done();
|
|
630
630
|
});
|
|
631
631
|
});
|
|
@@ -634,17 +634,17 @@ describe('Joi', function () {
|
|
|
634
634
|
|
|
635
635
|
Joi.object({}).validate({ foo: 'bar' }, function (err, value) {
|
|
636
636
|
|
|
637
|
-
expect(err).to.exist;
|
|
637
|
+
expect(err).to.exist();
|
|
638
638
|
expect(err.message).to.equal('foo is not allowed');
|
|
639
639
|
|
|
640
640
|
Joi.compile({}).validate({ foo: 'bar' }, function (err, value) {
|
|
641
641
|
|
|
642
|
-
expect(err).to.exist;
|
|
642
|
+
expect(err).to.exist();
|
|
643
643
|
expect(err.message).to.equal('foo is not allowed');
|
|
644
644
|
|
|
645
645
|
Joi.compile({ other: Joi.number() }).validate({ foo: 'bar' }, function (err, value) {
|
|
646
646
|
|
|
647
|
-
expect(err).to.exist;
|
|
647
|
+
expect(err).to.exist();
|
|
648
648
|
expect(err.message).to.equal('foo is not allowed');
|
|
649
649
|
|
|
650
650
|
done();
|
|
@@ -663,12 +663,12 @@ describe('Joi', function () {
|
|
|
663
663
|
|
|
664
664
|
Joi.compile(config).validate({ auth: { unknown: true } }, function (err, value) {
|
|
665
665
|
|
|
666
|
-
expect(err).to.not.be.null;
|
|
666
|
+
expect(err).to.not.be.null();
|
|
667
667
|
expect(err.message).to.contain('unknown is not allowed');
|
|
668
668
|
|
|
669
669
|
Joi.compile(config).validate({ something: false }, function (err, value) {
|
|
670
670
|
|
|
671
|
-
expect(err).to.not.be.null;
|
|
671
|
+
expect(err).to.not.be.null();
|
|
672
672
|
expect(err.message).to.contain('something is not allowed');
|
|
673
673
|
|
|
674
674
|
done();
|
|
@@ -690,22 +690,22 @@ describe('Joi', function () {
|
|
|
690
690
|
|
|
691
691
|
Joi.compile(config).validate({}, function (err, value) {
|
|
692
692
|
|
|
693
|
-
expect(err).to.exist;
|
|
693
|
+
expect(err).to.exist();
|
|
694
694
|
expect(err.message).to.contain('module is required');
|
|
695
695
|
|
|
696
696
|
Joi.compile(config).validate({ module: 'test' }, function (err, value) {
|
|
697
697
|
|
|
698
|
-
expect(err).to.be.null;
|
|
698
|
+
expect(err).to.be.null();
|
|
699
699
|
|
|
700
700
|
Joi.compile(config).validate({ module: {} }, function (err, value) {
|
|
701
701
|
|
|
702
|
-
expect(err).to.not.be.null;
|
|
702
|
+
expect(err).to.not.be.null();
|
|
703
703
|
expect(err.message).to.contain('compile is required');
|
|
704
704
|
expect(err.message).to.contain('module must be a string');
|
|
705
705
|
|
|
706
706
|
Joi.compile(config).validate({ module: { compile: function () { } } }, function (err, value) {
|
|
707
707
|
|
|
708
|
-
expect(err).to.be.null;
|
|
708
|
+
expect(err).to.be.null();
|
|
709
709
|
done();
|
|
710
710
|
});
|
|
711
711
|
});
|
|
@@ -727,7 +727,7 @@ describe('Joi', function () {
|
|
|
727
727
|
|
|
728
728
|
Joi.compile(config).validate({}, function (err, value) {
|
|
729
729
|
|
|
730
|
-
expect(err).to.not.exist;
|
|
730
|
+
expect(err).to.not.exist();
|
|
731
731
|
done();
|
|
732
732
|
});
|
|
733
733
|
});
|
|
@@ -746,7 +746,7 @@ describe('Joi', function () {
|
|
|
746
746
|
|
|
747
747
|
Joi.compile(config).validate({}, function (err, value) {
|
|
748
748
|
|
|
749
|
-
expect(err).to.exist;
|
|
749
|
+
expect(err).to.exist();
|
|
750
750
|
expect(err.message).to.contain('module is required');
|
|
751
751
|
done();
|
|
752
752
|
});
|
|
@@ -761,11 +761,11 @@ describe('Joi', function () {
|
|
|
761
761
|
|
|
762
762
|
Joi.compile(config).validate({ suggestion: 'something' }, function (err, value) {
|
|
763
763
|
|
|
764
|
-
expect(err).to.be.null;
|
|
764
|
+
expect(err).to.be.null();
|
|
765
765
|
|
|
766
766
|
Joi.compile(config).validate({ position: 1 }, function (err, value) {
|
|
767
767
|
|
|
768
|
-
expect(err).to.be.null;
|
|
768
|
+
expect(err).to.be.null();
|
|
769
769
|
done();
|
|
770
770
|
})
|
|
771
771
|
});
|
|
@@ -780,11 +780,11 @@ describe('Joi', function () {
|
|
|
780
780
|
|
|
781
781
|
Joi.compile(config).validate({ suggestion: {} }, function (err, value) {
|
|
782
782
|
|
|
783
|
-
expect(err).to.be.null;
|
|
783
|
+
expect(err).to.be.null();
|
|
784
784
|
|
|
785
785
|
Joi.compile(config).validate({ position: 1 }, function (err, value) {
|
|
786
786
|
|
|
787
|
-
expect(err).to.be.null;
|
|
787
|
+
expect(err).to.be.null();
|
|
788
788
|
done();
|
|
789
789
|
});
|
|
790
790
|
});
|
|
@@ -804,7 +804,7 @@ describe('Joi', function () {
|
|
|
804
804
|
|
|
805
805
|
Joi.compile(schema).validate(obj, function (err, value) {
|
|
806
806
|
|
|
807
|
-
expect(err).to.not.exist;
|
|
807
|
+
expect(err).to.not.exist();
|
|
808
808
|
done();
|
|
809
809
|
});
|
|
810
810
|
});
|
|
@@ -824,7 +824,7 @@ describe('Joi', function () {
|
|
|
824
824
|
|
|
825
825
|
Joi.compile(schema).validate(obj, function (err, value) {
|
|
826
826
|
|
|
827
|
-
expect(err).to.not.exist;
|
|
827
|
+
expect(err).to.not.exist();
|
|
828
828
|
done();
|
|
829
829
|
});
|
|
830
830
|
});
|
|
@@ -845,7 +845,7 @@ describe('Joi', function () {
|
|
|
845
845
|
|
|
846
846
|
Joi.compile(schema).validate(obj, function (err, value) {
|
|
847
847
|
|
|
848
|
-
expect(err).to.exist;
|
|
848
|
+
expect(err).to.exist();
|
|
849
849
|
done();
|
|
850
850
|
});
|
|
851
851
|
});
|
|
@@ -866,7 +866,7 @@ describe('Joi', function () {
|
|
|
866
866
|
|
|
867
867
|
Joi.compile(schema).validate(obj, function (err, value) {
|
|
868
868
|
|
|
869
|
-
expect(err).to.exist;
|
|
869
|
+
expect(err).to.exist();
|
|
870
870
|
done();
|
|
871
871
|
});
|
|
872
872
|
});
|
|
@@ -879,7 +879,7 @@ describe('Joi', function () {
|
|
|
879
879
|
|
|
880
880
|
Joi.compile({ a: Joi.string().required() }).validate(obj, function (err, value) {
|
|
881
881
|
|
|
882
|
-
expect(err).to.exist;
|
|
882
|
+
expect(err).to.exist();
|
|
883
883
|
done();
|
|
884
884
|
});
|
|
885
885
|
});
|
|
@@ -892,7 +892,7 @@ describe('Joi', function () {
|
|
|
892
892
|
|
|
893
893
|
Joi.compile({ a: Joi.object({ b: Joi.string().required() }) }).validate(obj, function (err, value) {
|
|
894
894
|
|
|
895
|
-
expect(err).to.exist;
|
|
895
|
+
expect(err).to.exist();
|
|
896
896
|
done();
|
|
897
897
|
});
|
|
898
898
|
});
|
|
@@ -905,7 +905,7 @@ describe('Joi', function () {
|
|
|
905
905
|
|
|
906
906
|
Joi.compile({ a: Joi.object({ b: Joi.string().required() }) }).validate(obj, function (err, value) {
|
|
907
907
|
|
|
908
|
-
expect(err).to.exist;
|
|
908
|
+
expect(err).to.exist();
|
|
909
909
|
done();
|
|
910
910
|
});
|
|
911
911
|
});
|
|
@@ -924,7 +924,7 @@ describe('Joi', function () {
|
|
|
924
924
|
|
|
925
925
|
Joi.validate(input, schema, function (err, value) {
|
|
926
926
|
|
|
927
|
-
expect(err).to.not.exist;
|
|
927
|
+
expect(err).to.not.exist();
|
|
928
928
|
expect(input.a).to.equal('{"b":"string"}');
|
|
929
929
|
expect(value.a.b).to.equal('string');
|
|
930
930
|
done();
|
|
@@ -939,7 +939,7 @@ describe('Joi', function () {
|
|
|
939
939
|
|
|
940
940
|
Joi.object({ a: Joi.object({ b: Joi.string().required() }) }).validate(obj, function (err, value) {
|
|
941
941
|
|
|
942
|
-
expect(err).to.exist;
|
|
942
|
+
expect(err).to.exist();
|
|
943
943
|
done();
|
|
944
944
|
});
|
|
945
945
|
});
|
|
@@ -952,7 +952,7 @@ describe('Joi', function () {
|
|
|
952
952
|
|
|
953
953
|
Joi.object({ a: Joi.array() }).validate(obj, function (err, value) {
|
|
954
954
|
|
|
955
|
-
expect(err).to.exist;
|
|
955
|
+
expect(err).to.exist();
|
|
956
956
|
done();
|
|
957
957
|
});
|
|
958
958
|
});
|
|
@@ -965,7 +965,7 @@ describe('Joi', function () {
|
|
|
965
965
|
|
|
966
966
|
Joi.object({ a: Joi.array() }).validate(obj, function (err, value) {
|
|
967
967
|
|
|
968
|
-
expect(err).to.be.null;
|
|
968
|
+
expect(err).to.be.null();
|
|
969
969
|
done();
|
|
970
970
|
});
|
|
971
971
|
});
|
|
@@ -978,7 +978,7 @@ describe('Joi', function () {
|
|
|
978
978
|
|
|
979
979
|
Joi.object({ a: Joi.object({ b: Joi.string().required() }) }).validate(obj, function (err, value) {
|
|
980
980
|
|
|
981
|
-
expect(err).to.exist;
|
|
981
|
+
expect(err).to.exist();
|
|
982
982
|
done();
|
|
983
983
|
});
|
|
984
984
|
});
|
|
@@ -997,7 +997,7 @@ describe('Joi', function () {
|
|
|
997
997
|
|
|
998
998
|
Joi.compile(schema).validate(obj, function (err, value) {
|
|
999
999
|
|
|
1000
|
-
expect(err).to.exist;
|
|
1000
|
+
expect(err).to.exist();
|
|
1001
1001
|
done();
|
|
1002
1002
|
});
|
|
1003
1003
|
});
|
|
@@ -1016,7 +1016,7 @@ describe('Joi', function () {
|
|
|
1016
1016
|
|
|
1017
1017
|
Joi.compile(schema).validate(obj, function (err, value) {
|
|
1018
1018
|
|
|
1019
|
-
expect(err).to.exist;
|
|
1019
|
+
expect(err).to.exist();
|
|
1020
1020
|
done();
|
|
1021
1021
|
});
|
|
1022
1022
|
});
|
|
@@ -1034,7 +1034,7 @@ describe('Joi', function () {
|
|
|
1034
1034
|
|
|
1035
1035
|
Joi.compile(schema).validate(obj, function (err, value) {
|
|
1036
1036
|
|
|
1037
|
-
expect(err).to.exist;
|
|
1037
|
+
expect(err).to.exist();
|
|
1038
1038
|
done();
|
|
1039
1039
|
});
|
|
1040
1040
|
});
|
|
@@ -1047,7 +1047,7 @@ describe('Joi', function () {
|
|
|
1047
1047
|
|
|
1048
1048
|
Joi.compile(schema).validate({}, function (err, value) {
|
|
1049
1049
|
|
|
1050
|
-
expect(err).to.not.exist;
|
|
1050
|
+
expect(err).to.not.exist();
|
|
1051
1051
|
done();
|
|
1052
1052
|
});
|
|
1053
1053
|
});
|
|
@@ -1068,7 +1068,7 @@ describe('Joi', function () {
|
|
|
1068
1068
|
|
|
1069
1069
|
Joi.validate(obj, schema, { stripUnknown: true, allowUnknown: true }, function (err, value) {
|
|
1070
1070
|
|
|
1071
|
-
expect(err).to.be.null;
|
|
1071
|
+
expect(err).to.be.null();
|
|
1072
1072
|
expect(value).to.deep.equal({ a: 1, b: 'a' });
|
|
1073
1073
|
done();
|
|
1074
1074
|
});
|
|
@@ -1090,7 +1090,7 @@ describe('Joi', function () {
|
|
|
1090
1090
|
|
|
1091
1091
|
Joi.validate(obj, schema, { stripUnknown: true, abortEarly: false }, function (err, value) {
|
|
1092
1092
|
|
|
1093
|
-
expect(err).to.exist;
|
|
1093
|
+
expect(err).to.exist();
|
|
1094
1094
|
done();
|
|
1095
1095
|
});
|
|
1096
1096
|
});
|
|
@@ -1111,7 +1111,7 @@ describe('Joi', function () {
|
|
|
1111
1111
|
|
|
1112
1112
|
Joi.validate(obj, schema, { allowUnknown: true }, function (err, value) {
|
|
1113
1113
|
|
|
1114
|
-
expect(err).to.be.null;
|
|
1114
|
+
expect(err).to.be.null();
|
|
1115
1115
|
expect(value).to.deep.equal({ a: 1, b: 'a', d: 'c' });
|
|
1116
1116
|
done();
|
|
1117
1117
|
});
|
|
@@ -1132,12 +1132,12 @@ describe('Joi', function () {
|
|
|
1132
1132
|
|
|
1133
1133
|
localConfig.validate(obj, function (err, value) {
|
|
1134
1134
|
|
|
1135
|
-
expect(err).to.be.null;
|
|
1135
|
+
expect(err).to.be.null();
|
|
1136
1136
|
expect(value).to.deep.equal({ a: 1, b: 'a', d: 'c' });
|
|
1137
1137
|
|
|
1138
1138
|
localConfig.validate(value, function (err, value) {
|
|
1139
1139
|
|
|
1140
|
-
expect(err).to.be.null;
|
|
1140
|
+
expect(err).to.be.null();
|
|
1141
1141
|
expect(value).to.deep.equal({ a: 1, b: 'a', d: 'c' });
|
|
1142
1142
|
done();
|
|
1143
1143
|
});
|
|
@@ -1160,12 +1160,12 @@ describe('Joi', function () {
|
|
|
1160
1160
|
|
|
1161
1161
|
localConfig.validate(obj, function (err, value) {
|
|
1162
1162
|
|
|
1163
|
-
expect(err).to.be.null;
|
|
1163
|
+
expect(err).to.be.null();
|
|
1164
1164
|
expect(value).to.deep.equal({ a: 1, b: 'a' });
|
|
1165
1165
|
|
|
1166
1166
|
localConfig.validate(value, function (err, value) {
|
|
1167
1167
|
|
|
1168
|
-
expect(err).to.be.null;
|
|
1168
|
+
expect(err).to.be.null();
|
|
1169
1169
|
expect(value).to.deep.equal({ a: 1, b: 'a' });
|
|
1170
1170
|
done();
|
|
1171
1171
|
});
|
|
@@ -1178,7 +1178,7 @@ describe('Joi', function () {
|
|
|
1178
1178
|
var input = { username: 'test', func: function () { } };
|
|
1179
1179
|
Joi.validate(input, schema, function (err, value) {
|
|
1180
1180
|
|
|
1181
|
-
expect(err).to.not.exist;
|
|
1181
|
+
expect(err).to.not.exist();
|
|
1182
1182
|
done();
|
|
1183
1183
|
});
|
|
1184
1184
|
});
|
|
@@ -1190,7 +1190,7 @@ describe('Joi', function () {
|
|
|
1190
1190
|
|
|
1191
1191
|
Joi.validate(input, schema, { skipFunctions: false }, function (err, value) {
|
|
1192
1192
|
|
|
1193
|
-
expect(err).to.exist;
|
|
1193
|
+
expect(err).to.exist();
|
|
1194
1194
|
expect(err.message).to.contain('func is not allowed');
|
|
1195
1195
|
done();
|
|
1196
1196
|
});
|
|
@@ -1205,7 +1205,7 @@ describe('Joi', function () {
|
|
|
1205
1205
|
var input = { arr: 'foo' };
|
|
1206
1206
|
Joi.validate(input, schema, { convert: false }, function (err, value) {
|
|
1207
1207
|
|
|
1208
|
-
expect(err).to.exist;
|
|
1208
|
+
expect(err).to.exist();
|
|
1209
1209
|
done();
|
|
1210
1210
|
});
|
|
1211
1211
|
});
|
|
@@ -1223,8 +1223,8 @@ describe('Joi', function () {
|
|
|
1223
1223
|
|
|
1224
1224
|
Joi.validate(input, schema, { abortEarly: false }, function (errFull, value) {
|
|
1225
1225
|
|
|
1226
|
-
expect(errOne).to.exist
|
|
1227
|
-
expect(errFull).to.exist
|
|
1226
|
+
expect(errOne).to.exist();
|
|
1227
|
+
expect(errFull).to.exist();
|
|
1228
1228
|
expect(errFull.details.length).to.be.greaterThan(errOne.details.length);
|
|
1229
1229
|
done();
|
|
1230
1230
|
});
|
|
@@ -1236,7 +1236,7 @@ describe('Joi', function () {
|
|
|
1236
1236
|
var any = Joi;
|
|
1237
1237
|
any.validate('abc', function (err, value) {
|
|
1238
1238
|
|
|
1239
|
-
expect(err).to.not.exist;
|
|
1239
|
+
expect(err).to.not.exist();
|
|
1240
1240
|
done();
|
|
1241
1241
|
});
|
|
1242
1242
|
});
|
|
@@ -1245,7 +1245,7 @@ describe('Joi', function () {
|
|
|
1245
1245
|
|
|
1246
1246
|
var any = Joi;
|
|
1247
1247
|
var result = any.validate('abc');
|
|
1248
|
-
expect(result.error).to.not.exist;
|
|
1248
|
+
expect(result.error).to.not.exist();
|
|
1249
1249
|
expect(result.value).to.equal('abc');
|
|
1250
1250
|
done();
|
|
1251
1251
|
});
|
|
@@ -1254,7 +1254,7 @@ describe('Joi', function () {
|
|
|
1254
1254
|
|
|
1255
1255
|
Joi.validate('test', Joi.string(), function (err, value) {
|
|
1256
1256
|
|
|
1257
|
-
expect(err).to.not.exist;
|
|
1257
|
+
expect(err).to.not.exist();
|
|
1258
1258
|
done();
|
|
1259
1259
|
});
|
|
1260
1260
|
});
|
|
@@ -1262,7 +1262,7 @@ describe('Joi', function () {
|
|
|
1262
1262
|
it('accepts no options (no callback)', function (done) {
|
|
1263
1263
|
|
|
1264
1264
|
var result = Joi.validate('test', Joi.string());
|
|
1265
|
-
expect(result.error).to.not.exist;
|
|
1265
|
+
expect(result.error).to.not.exist();
|
|
1266
1266
|
expect(result.value).to.equal('test');
|
|
1267
1267
|
done();
|
|
1268
1268
|
});
|
|
@@ -1271,7 +1271,7 @@ describe('Joi', function () {
|
|
|
1271
1271
|
|
|
1272
1272
|
Joi.validate('5', Joi.number(), { convert: false }, function (err, value) {
|
|
1273
1273
|
|
|
1274
|
-
expect(err).to.exist;
|
|
1274
|
+
expect(err).to.exist();
|
|
1275
1275
|
done();
|
|
1276
1276
|
});
|
|
1277
1277
|
});
|
|
@@ -1279,7 +1279,7 @@ describe('Joi', function () {
|
|
|
1279
1279
|
it('accepts options (no callback)', function (done) {
|
|
1280
1280
|
|
|
1281
1281
|
var result = Joi.validate('5', Joi.number(), { convert: false });
|
|
1282
|
-
expect(result.error).to.exist;
|
|
1282
|
+
expect(result.error).to.exist();
|
|
1283
1283
|
done();
|
|
1284
1284
|
});
|
|
1285
1285
|
|
|
@@ -1287,7 +1287,7 @@ describe('Joi', function () {
|
|
|
1287
1287
|
|
|
1288
1288
|
Joi.validate('test', Joi.string(), null, function (err, value) {
|
|
1289
1289
|
|
|
1290
|
-
expect(err).to.not.exist;
|
|
1290
|
+
expect(err).to.not.exist();
|
|
1291
1291
|
done();
|
|
1292
1292
|
});
|
|
1293
1293
|
});
|
|
@@ -1296,7 +1296,7 @@ describe('Joi', function () {
|
|
|
1296
1296
|
|
|
1297
1297
|
Joi.validate('test', Joi.string(), undefined, function (err, value) {
|
|
1298
1298
|
|
|
1299
|
-
expect(err).to.not.exist;
|
|
1299
|
+
expect(err).to.not.exist();
|
|
1300
1300
|
done();
|
|
1301
1301
|
});
|
|
1302
1302
|
});
|
|
@@ -1431,7 +1431,7 @@ describe('Joi', function () {
|
|
|
1431
1431
|
it('describes schema without invalids', function (done) {
|
|
1432
1432
|
|
|
1433
1433
|
var description = Joi.allow(null).describe();
|
|
1434
|
-
expect(description.invalids).to.not.exist;
|
|
1434
|
+
expect(description.invalids).to.not.exist();
|
|
1435
1435
|
done();
|
|
1436
1436
|
})
|
|
1437
1437
|
});
|
package/test/number.js
CHANGED
|
@@ -53,7 +53,7 @@ describe('number', function () {
|
|
|
53
53
|
var text = Joi.number().invalid(50);
|
|
54
54
|
text.validate(50, function (err, value) {
|
|
55
55
|
|
|
56
|
-
expect(err).to.exist;
|
|
56
|
+
expect(err).to.exist();
|
|
57
57
|
done();
|
|
58
58
|
});
|
|
59
59
|
});
|
|
@@ -103,7 +103,7 @@ describe('number', function () {
|
|
|
103
103
|
|
|
104
104
|
Joi.compile(config).validate(obj, function (err, value) {
|
|
105
105
|
|
|
106
|
-
expect(err).to.not.exist;
|
|
106
|
+
expect(err).to.not.exist();
|
|
107
107
|
expect(value.a).to.equal(123);
|
|
108
108
|
done();
|
|
109
109
|
});
|
|
@@ -113,7 +113,7 @@ describe('number', function () {
|
|
|
113
113
|
|
|
114
114
|
Joi.number().validate('1', function (err, value) {
|
|
115
115
|
|
|
116
|
-
expect(err).to.not.exist;
|
|
116
|
+
expect(err).to.not.exist();
|
|
117
117
|
expect(value).to.equal(1);
|
|
118
118
|
done();
|
|
119
119
|
});
|
|
@@ -123,7 +123,7 @@ describe('number', function () {
|
|
|
123
123
|
|
|
124
124
|
Joi.number().validate(null, function (err, value) {
|
|
125
125
|
|
|
126
|
-
expect(err).to.exist;
|
|
126
|
+
expect(err).to.exist();
|
|
127
127
|
expect(value).to.equal(null);
|
|
128
128
|
done();
|
|
129
129
|
});
|
|
@@ -479,7 +479,7 @@ describe('number', function () {
|
|
|
479
479
|
it('should show resulting object with #valueOf', function (done) {
|
|
480
480
|
|
|
481
481
|
var result = Joi.number().min(5);
|
|
482
|
-
expect(result.valueOf()).to.exist;
|
|
482
|
+
expect(result.valueOf()).to.exist();
|
|
483
483
|
done();
|
|
484
484
|
});
|
|
485
485
|
|
|
@@ -514,7 +514,7 @@ describe('number', function () {
|
|
|
514
514
|
|
|
515
515
|
schema.validate(input, function (err, value) {
|
|
516
516
|
|
|
517
|
-
expect(err).to.not.exist;
|
|
517
|
+
expect(err).to.not.exist();
|
|
518
518
|
expect(value).to.equal(input);
|
|
519
519
|
done();
|
|
520
520
|
});
|