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/object.js
CHANGED
|
@@ -27,7 +27,7 @@ describe('object', function () {
|
|
|
27
27
|
|
|
28
28
|
Joi.object().validate('{"hi":true}', function (err, value) {
|
|
29
29
|
|
|
30
|
-
expect(err).to.not.exist;
|
|
30
|
+
expect(err).to.not.exist();
|
|
31
31
|
expect(value.hi).to.equal(true);
|
|
32
32
|
done();
|
|
33
33
|
});
|
|
@@ -37,7 +37,7 @@ describe('object', function () {
|
|
|
37
37
|
|
|
38
38
|
Joi.object().validate('a string', function (err, value) {
|
|
39
39
|
|
|
40
|
-
expect(err).to.exist;
|
|
40
|
+
expect(err).to.exist();
|
|
41
41
|
expect(value).to.equal('a string');
|
|
42
42
|
done();
|
|
43
43
|
});
|
|
@@ -92,11 +92,11 @@ describe('object', function () {
|
|
|
92
92
|
|
|
93
93
|
Joi.object().validate({ a: 4 }, function (err, value) {
|
|
94
94
|
|
|
95
|
-
expect(err).to.not.exist;
|
|
95
|
+
expect(err).to.not.exist();
|
|
96
96
|
|
|
97
97
|
Joi.object(undefined).validate({ a: 4 }, function (err, value) {
|
|
98
98
|
|
|
99
|
-
expect(err).to.not.exist;
|
|
99
|
+
expect(err).to.not.exist();
|
|
100
100
|
done();
|
|
101
101
|
});
|
|
102
102
|
});
|
|
@@ -106,7 +106,7 @@ describe('object', function () {
|
|
|
106
106
|
|
|
107
107
|
Joi.object(null).validate({ a: 4 }, function (err, value) {
|
|
108
108
|
|
|
109
|
-
expect(err).to.not.exist;
|
|
109
|
+
expect(err).to.not.exist();
|
|
110
110
|
done();
|
|
111
111
|
});
|
|
112
112
|
});
|
|
@@ -133,8 +133,8 @@ describe('object', function () {
|
|
|
133
133
|
|
|
134
134
|
Joi.object({ a: Joi.object() }).validate(undefined, function (err, value) {
|
|
135
135
|
|
|
136
|
-
expect(err).to.not.exist;
|
|
137
|
-
expect(value).to.not.exist;
|
|
136
|
+
expect(err).to.not.exist();
|
|
137
|
+
expect(value).to.not.exist();
|
|
138
138
|
done();
|
|
139
139
|
});
|
|
140
140
|
});
|
|
@@ -143,7 +143,7 @@ describe('object', function () {
|
|
|
143
143
|
|
|
144
144
|
Joi.object().validate([1, 2, 3], function (err, value) {
|
|
145
145
|
|
|
146
|
-
expect(err).to.exist;
|
|
146
|
+
expect(err).to.exist();
|
|
147
147
|
done();
|
|
148
148
|
});
|
|
149
149
|
});
|
|
@@ -203,6 +203,18 @@ describe('object', function () {
|
|
|
203
203
|
], done);
|
|
204
204
|
});
|
|
205
205
|
|
|
206
|
+
it('should validate constructor when type is set', function (done) {
|
|
207
|
+
|
|
208
|
+
var schema = Joi.object().type(RegExp);
|
|
209
|
+
Helper.validate(schema, [
|
|
210
|
+
[{ item: 'something' }, false],
|
|
211
|
+
['', false],
|
|
212
|
+
[new Date(), false],
|
|
213
|
+
[/abcd/, true],
|
|
214
|
+
[new RegExp(), true]
|
|
215
|
+
], done);
|
|
216
|
+
});
|
|
217
|
+
|
|
206
218
|
it('should traverse an object and validate all properties in the top level', function (done) {
|
|
207
219
|
|
|
208
220
|
var schema = Joi.object({
|
|
@@ -308,7 +320,7 @@ describe('object', function () {
|
|
|
308
320
|
var obj = { a: 5, b: 'value' };
|
|
309
321
|
schema.validate(obj, function (err, value) {
|
|
310
322
|
|
|
311
|
-
expect(err).to.exist;
|
|
323
|
+
expect(err).to.exist();
|
|
312
324
|
done();
|
|
313
325
|
});
|
|
314
326
|
});
|
|
@@ -333,10 +345,10 @@ describe('object', function () {
|
|
|
333
345
|
var b = a.keys();
|
|
334
346
|
a.validate({ b: 3 }, function (err, value) {
|
|
335
347
|
|
|
336
|
-
expect(err).to.exist;
|
|
348
|
+
expect(err).to.exist();
|
|
337
349
|
b.validate({ b: 3 }, function (err, value) {
|
|
338
350
|
|
|
339
|
-
expect(err).to.not.exist;
|
|
351
|
+
expect(err).to.not.exist();
|
|
340
352
|
done();
|
|
341
353
|
});
|
|
342
354
|
});
|
|
@@ -348,10 +360,10 @@ describe('object', function () {
|
|
|
348
360
|
var b = a.keys({});
|
|
349
361
|
a.validate({ b: 3 }, function (err, value) {
|
|
350
362
|
|
|
351
|
-
expect(err).to.not.exist;
|
|
363
|
+
expect(err).to.not.exist();
|
|
352
364
|
b.validate({ b: 3 }, function (err, value) {
|
|
353
365
|
|
|
354
|
-
expect(err).to.exist;
|
|
366
|
+
expect(err).to.exist();
|
|
355
367
|
done();
|
|
356
368
|
});
|
|
357
369
|
});
|
|
@@ -363,10 +375,10 @@ describe('object', function () {
|
|
|
363
375
|
var b = a.keys({ b: 2 });
|
|
364
376
|
a.validate({ a: 1, b: 2 }, function (err, value) {
|
|
365
377
|
|
|
366
|
-
expect(err).to.exist;
|
|
378
|
+
expect(err).to.exist();
|
|
367
379
|
b.validate({ a: 1, b: 2 }, function (err, value) {
|
|
368
380
|
|
|
369
|
-
expect(err).to.not.exist;
|
|
381
|
+
expect(err).to.not.exist();
|
|
370
382
|
done();
|
|
371
383
|
});
|
|
372
384
|
});
|
|
@@ -418,7 +430,7 @@ describe('object', function () {
|
|
|
418
430
|
|
|
419
431
|
Joi.compile(schema).validate({ test1: 'a', test2: 'b' }, function (err, value) {
|
|
420
432
|
|
|
421
|
-
expect(err).to.not.exist;
|
|
433
|
+
expect(err).to.not.exist();
|
|
422
434
|
done();
|
|
423
435
|
});
|
|
424
436
|
});
|
|
@@ -440,7 +452,7 @@ describe('object', function () {
|
|
|
440
452
|
|
|
441
453
|
Joi.object().rename('a', 'b').rename('c', 'b').rename('d', 'b').options({ abortEarly: false }).validate({ a: 1, c: 1, d: 1 }, function (err, value) {
|
|
442
454
|
|
|
443
|
-
expect(err).to.exist;
|
|
455
|
+
expect(err).to.exist();
|
|
444
456
|
expect(err.message).to.equal('value cannot rename child c because multiple renames are disabled and another key was already renamed to b. value cannot rename child d because multiple renames are disabled and another key was already renamed to b');
|
|
445
457
|
done();
|
|
446
458
|
});
|
|
@@ -457,7 +469,7 @@ describe('object', function () {
|
|
|
457
469
|
|
|
458
470
|
Joi.compile(schema).validate(obj, function (err, value) {
|
|
459
471
|
|
|
460
|
-
expect(err).to.not.exist;
|
|
472
|
+
expect(err).to.not.exist();
|
|
461
473
|
expect(value.a).to.equal(10);
|
|
462
474
|
expect(value.b).to.equal(10);
|
|
463
475
|
done();
|
|
@@ -485,7 +497,7 @@ describe('object', function () {
|
|
|
485
497
|
|
|
486
498
|
schema.validate({ test: 'b', test1: 'a' }, function (err, value) {
|
|
487
499
|
|
|
488
|
-
expect(err).to.not.exist;
|
|
500
|
+
expect(err).to.not.exist();
|
|
489
501
|
done();
|
|
490
502
|
});
|
|
491
503
|
});
|
|
@@ -502,7 +514,7 @@ describe('object', function () {
|
|
|
502
514
|
var data = { arr: [{ uno: '1', dos: '2' }] };
|
|
503
515
|
Joi.object(schema).validate(data, function (err, value) {
|
|
504
516
|
|
|
505
|
-
expect(err).to.not.exist;
|
|
517
|
+
expect(err).to.not.exist();
|
|
506
518
|
expect(value.arr[0].one).to.equal('1');
|
|
507
519
|
expect(value.arr[0].two).to.equal('2');
|
|
508
520
|
done();
|
|
@@ -519,8 +531,8 @@ describe('object', function () {
|
|
|
519
531
|
|
|
520
532
|
schema1.validate(input1, function (err1, value1) {
|
|
521
533
|
|
|
522
|
-
expect(err1).to.not.exist;
|
|
523
|
-
expect(value1.b).to.not.exist;
|
|
534
|
+
expect(err1).to.not.exist();
|
|
535
|
+
expect(value1.b).to.not.exist();
|
|
524
536
|
expect(value1.a).to.equal(5);
|
|
525
537
|
|
|
526
538
|
var schema2 = Joi.object({ a: Joi.number(), b: Joi.any() }).rename('b', 'a');
|
|
@@ -528,8 +540,8 @@ describe('object', function () {
|
|
|
528
540
|
|
|
529
541
|
schema2.validate(input2, function (err2, value2) {
|
|
530
542
|
|
|
531
|
-
expect(err2).to.not.exist;
|
|
532
|
-
expect(value2.b).to.not.exist;
|
|
543
|
+
expect(err2).to.not.exist();
|
|
544
|
+
expect(value2.b).to.not.exist();
|
|
533
545
|
expect(value2.a).to.equal(5);
|
|
534
546
|
|
|
535
547
|
done();
|
|
@@ -547,7 +559,7 @@ describe('object', function () {
|
|
|
547
559
|
|
|
548
560
|
Joi.validate(input, schema, function (err, value) {
|
|
549
561
|
|
|
550
|
-
expect(err).to.not.exist;
|
|
562
|
+
expect(err).to.not.exist();
|
|
551
563
|
expect(value.foo2).to.equal('test');
|
|
552
564
|
|
|
553
565
|
done();
|
|
@@ -563,8 +575,8 @@ describe('object', function () {
|
|
|
563
575
|
|
|
564
576
|
schema.validate(input, function (err, value) {
|
|
565
577
|
|
|
566
|
-
expect(err).to.not.exist;
|
|
567
|
-
expect(value['']).to.not.exist;
|
|
578
|
+
expect(err).to.not.exist();
|
|
579
|
+
expect(value['']).to.not.exist();
|
|
568
580
|
expect(value.notEmpty).to.equal('something');
|
|
569
581
|
done();
|
|
570
582
|
});
|
|
@@ -580,7 +592,7 @@ describe('object', function () {
|
|
|
580
592
|
|
|
581
593
|
schema.validate(input, function (err, value) {
|
|
582
594
|
|
|
583
|
-
expect(err).to.not.exist;
|
|
595
|
+
expect(err).to.not.exist();
|
|
584
596
|
expect(Object.keys(value)).to.include('a');
|
|
585
597
|
expect(value.a).to.equal('something');
|
|
586
598
|
done();
|
|
@@ -689,7 +701,7 @@ describe('object', function () {
|
|
|
689
701
|
|
|
690
702
|
Joi.validate({ bb: 'y', 5: 'x' }, schema, { abortEarly: false }, function (err, value) {
|
|
691
703
|
|
|
692
|
-
expect(err).to.exist;
|
|
704
|
+
expect(err).to.exist();
|
|
693
705
|
expect(err.message).to.equal('5 must be a boolean. bb must be one of x');
|
|
694
706
|
|
|
695
707
|
Helper.validate(schema, [
|
|
@@ -714,7 +726,7 @@ describe('object', function () {
|
|
|
714
726
|
|
|
715
727
|
Joi.validate({ x: { bb: 'y', 5: 'x' } }, schema, { abortEarly: false }, function (err, value) {
|
|
716
728
|
|
|
717
|
-
expect(err).to.exist;
|
|
729
|
+
expect(err).to.exist();
|
|
718
730
|
expect(err.message).to.equal('5 must be a boolean. bb must be one of x');
|
|
719
731
|
done();
|
|
720
732
|
});
|
|
@@ -726,7 +738,7 @@ describe('object', function () {
|
|
|
726
738
|
|
|
727
739
|
Joi.validate({ a: 5 }, schema, { abortEarly: false }, function (err, value) {
|
|
728
740
|
|
|
729
|
-
expect(err).to.exist;
|
|
741
|
+
expect(err).to.exist();
|
|
730
742
|
expect(err.message).to.equal('a is not allowed');
|
|
731
743
|
done();
|
|
732
744
|
});
|
|
@@ -738,7 +750,7 @@ describe('object', function () {
|
|
|
738
750
|
|
|
739
751
|
Joi.validate({ a1: 5, a2: 6 }, schema, function (err, value) {
|
|
740
752
|
|
|
741
|
-
expect(err).to.not.exist;
|
|
753
|
+
expect(err).to.not.exist();
|
|
742
754
|
done();
|
|
743
755
|
});
|
|
744
756
|
});
|
|
@@ -871,7 +883,7 @@ describe('object', function () {
|
|
|
871
883
|
}
|
|
872
884
|
}).validate({ a: { b: { c: 1 } } }, function (err, value) {
|
|
873
885
|
|
|
874
|
-
expect(err).to.exist;
|
|
886
|
+
expect(err).to.exist();
|
|
875
887
|
expect(err.message).to.equal('value must contain at least one of x, y');
|
|
876
888
|
done();
|
|
877
889
|
});
|
|
@@ -894,7 +906,7 @@ describe('object', function () {
|
|
|
894
906
|
|
|
895
907
|
schema.validate({ a: { b: 'x', c: 5 }, d: { e: 6 } }, function (err, value) {
|
|
896
908
|
|
|
897
|
-
expect(err).to.exist;
|
|
909
|
+
expect(err).to.exist();
|
|
898
910
|
expect(err.message).to.equal('value validation failed because d.e failed to equal to a.c');
|
|
899
911
|
|
|
900
912
|
Helper.validate(schema, [
|
|
@@ -917,7 +929,7 @@ describe('object', function () {
|
|
|
917
929
|
|
|
918
930
|
schema.validate({ a: { b: 'x', c: 5 }, d: { e: 6 } }, function (err, value) {
|
|
919
931
|
|
|
920
|
-
expect(err).to.exist;
|
|
932
|
+
expect(err).to.exist();
|
|
921
933
|
expect(err.message).to.equal('value validation failed because d.e failed to equal to a.c');
|
|
922
934
|
|
|
923
935
|
Helper.validate(schema, [
|
|
@@ -978,10 +990,69 @@ describe('object', function () {
|
|
|
978
990
|
}
|
|
979
991
|
}, function (err) {
|
|
980
992
|
|
|
981
|
-
expect(err).to.exist;
|
|
993
|
+
expect(err).to.exist();
|
|
982
994
|
expect(err.message).to.equal('value validation failed because d.e failed to pass the assertion test');
|
|
983
995
|
done();
|
|
984
996
|
});
|
|
985
997
|
});
|
|
986
998
|
});
|
|
999
|
+
|
|
1000
|
+
describe('#type', function () {
|
|
1001
|
+
|
|
1002
|
+
it('uses constructor name for default type name', function (done) {
|
|
1003
|
+
|
|
1004
|
+
function Foo () {}
|
|
1005
|
+
|
|
1006
|
+
var schema = Joi.object().type(Foo);
|
|
1007
|
+
schema.validate({}, function (err) {
|
|
1008
|
+
|
|
1009
|
+
expect(err).to.exist();
|
|
1010
|
+
expect(err.message).to.equal('value must be an instance of Foo');
|
|
1011
|
+
done();
|
|
1012
|
+
});
|
|
1013
|
+
});
|
|
1014
|
+
|
|
1015
|
+
it('uses custom type name if supplied', function (done) {
|
|
1016
|
+
|
|
1017
|
+
var Foo = function () {};
|
|
1018
|
+
|
|
1019
|
+
var schema = Joi.object().type(Foo, 'Bar');
|
|
1020
|
+
schema.validate({}, function (err) {
|
|
1021
|
+
|
|
1022
|
+
expect(err).to.exist();
|
|
1023
|
+
expect(err.message).to.equal('value must be an instance of Bar');
|
|
1024
|
+
done();
|
|
1025
|
+
});
|
|
1026
|
+
});
|
|
1027
|
+
|
|
1028
|
+
it('overrides constructor name with custom name', function (done) {
|
|
1029
|
+
|
|
1030
|
+
function Foo () {}
|
|
1031
|
+
|
|
1032
|
+
var schema = Joi.object().type(Foo, 'Bar');
|
|
1033
|
+
schema.validate({}, function (err) {
|
|
1034
|
+
|
|
1035
|
+
expect(err).to.exist();
|
|
1036
|
+
expect(err.message).to.equal('value must be an instance of Bar');
|
|
1037
|
+
done();
|
|
1038
|
+
});
|
|
1039
|
+
});
|
|
1040
|
+
|
|
1041
|
+
it('throws when constructor is not a function', function (done) {
|
|
1042
|
+
|
|
1043
|
+
expect(function () {
|
|
1044
|
+
|
|
1045
|
+
var schema = Joi.object().type('');
|
|
1046
|
+
}).to.throw('type must be a constructor function');
|
|
1047
|
+
done();
|
|
1048
|
+
});
|
|
1049
|
+
|
|
1050
|
+
it('uses the constructor name in the schema description', function (done) {
|
|
1051
|
+
|
|
1052
|
+
var description = Joi.object().type(RegExp).describe();
|
|
1053
|
+
|
|
1054
|
+
expect(description.rules).to.deep.include({ name: 'type', arg: 'RegExp' });
|
|
1055
|
+
done();
|
|
1056
|
+
});
|
|
1057
|
+
});
|
|
987
1058
|
});
|
package/test/ref.js
CHANGED
|
@@ -32,7 +32,7 @@ describe('ref', function () {
|
|
|
32
32
|
|
|
33
33
|
schema.validate({ a: 5, b: 6 }, function (err, value) {
|
|
34
34
|
|
|
35
|
-
expect(err).to.exist;
|
|
35
|
+
expect(err).to.exist();
|
|
36
36
|
expect(err.message).to.equal('a must be one of ref:b');
|
|
37
37
|
|
|
38
38
|
Helper.validate(schema, [
|
|
@@ -53,7 +53,7 @@ describe('ref', function () {
|
|
|
53
53
|
|
|
54
54
|
schema.validate({ a: 5, '': 6 }, function (err, value) {
|
|
55
55
|
|
|
56
|
-
expect(err).to.exist;
|
|
56
|
+
expect(err).to.exist();
|
|
57
57
|
expect(err.message).to.equal('a must be one of ref:');
|
|
58
58
|
|
|
59
59
|
Helper.validate(schema, [
|
|
@@ -76,7 +76,7 @@ describe('ref', function () {
|
|
|
76
76
|
|
|
77
77
|
schema.validate({ a: 5, b: { c: 6 } }, function (err, value) {
|
|
78
78
|
|
|
79
|
-
expect(err).to.exist;
|
|
79
|
+
expect(err).to.exist();
|
|
80
80
|
expect(err.message).to.equal('a must be one of ref:b.c');
|
|
81
81
|
|
|
82
82
|
Helper.validate(schema, [
|
|
@@ -103,7 +103,7 @@ describe('ref', function () {
|
|
|
103
103
|
var input = { a: 5, b: { c: 5 } };
|
|
104
104
|
schema.validate(input, function (err, value) {
|
|
105
105
|
|
|
106
|
-
expect(err).to.not.exist;
|
|
106
|
+
expect(err).to.not.exist();
|
|
107
107
|
|
|
108
108
|
var parent = Joi.object({
|
|
109
109
|
e: schema
|
|
@@ -111,7 +111,7 @@ describe('ref', function () {
|
|
|
111
111
|
|
|
112
112
|
parent.validate({ e: input }, function (err, value) {
|
|
113
113
|
|
|
114
|
-
expect(err).to.not.exist;
|
|
114
|
+
expect(err).to.not.exist();
|
|
115
115
|
done();
|
|
116
116
|
});
|
|
117
117
|
});
|
|
@@ -131,7 +131,7 @@ describe('ref', function () {
|
|
|
131
131
|
|
|
132
132
|
schema.validate({ a: 5, b: { c: 5 } }, function (err, value) {
|
|
133
133
|
|
|
134
|
-
expect(err).to.not.exist;
|
|
134
|
+
expect(err).to.not.exist();
|
|
135
135
|
done();
|
|
136
136
|
});
|
|
137
137
|
});
|
|
@@ -147,7 +147,7 @@ describe('ref', function () {
|
|
|
147
147
|
|
|
148
148
|
ab.validate({ a: { c: '5' }, b: 5 }, function (err, value) {
|
|
149
149
|
|
|
150
|
-
expect(err).to.not.exist;
|
|
150
|
+
expect(err).to.not.exist();
|
|
151
151
|
|
|
152
152
|
var ba = Joi.object({
|
|
153
153
|
b: Joi.ref('a.c'),
|
|
@@ -158,7 +158,7 @@ describe('ref', function () {
|
|
|
158
158
|
|
|
159
159
|
ba.validate({ a: { c: '5' }, b: 5 }, function (err, value) {
|
|
160
160
|
|
|
161
|
-
expect(err).to.not.exist;
|
|
161
|
+
expect(err).to.not.exist();
|
|
162
162
|
done();
|
|
163
163
|
});
|
|
164
164
|
});
|
|
@@ -173,7 +173,7 @@ describe('ref', function () {
|
|
|
173
173
|
|
|
174
174
|
schema.validate({ b: 6 }, function (err, value) {
|
|
175
175
|
|
|
176
|
-
expect(err).to.not.exist;
|
|
176
|
+
expect(err).to.not.exist();
|
|
177
177
|
expect(value).to.deep.equal({ a: 6, b: 6 });
|
|
178
178
|
done();
|
|
179
179
|
});
|
|
@@ -188,7 +188,7 @@ describe('ref', function () {
|
|
|
188
188
|
|
|
189
189
|
ab.validate({ b: '6' }, function (err, value) {
|
|
190
190
|
|
|
191
|
-
expect(err).to.not.exist;
|
|
191
|
+
expect(err).to.not.exist();
|
|
192
192
|
expect(value).to.deep.equal({ a: 6, b: 6 });
|
|
193
193
|
|
|
194
194
|
var ba = Joi.object({
|
|
@@ -198,7 +198,7 @@ describe('ref', function () {
|
|
|
198
198
|
|
|
199
199
|
ba.validate({ b: '6' }, function (err, value) {
|
|
200
200
|
|
|
201
|
-
expect(err).to.not.exist;
|
|
201
|
+
expect(err).to.not.exist();
|
|
202
202
|
expect(value).to.deep.equal({ a: 6, b: 6 });
|
|
203
203
|
done();
|
|
204
204
|
});
|
|
@@ -263,7 +263,7 @@ describe('ref', function () {
|
|
|
263
263
|
|
|
264
264
|
Joi.validate({ b: 6 }, schema, { context: { x: 22 } }, function (err, value) {
|
|
265
265
|
|
|
266
|
-
expect(err).to.not.exist;
|
|
266
|
+
expect(err).to.not.exist();
|
|
267
267
|
expect(value).to.deep.equal({ a: 22, b: 6 });
|
|
268
268
|
done();
|
|
269
269
|
});
|
|
@@ -278,7 +278,7 @@ describe('ref', function () {
|
|
|
278
278
|
|
|
279
279
|
Joi.validate({ b: 6 }, schema, { context: { x: 22 } }, function (err, value) {
|
|
280
280
|
|
|
281
|
-
expect(err).to.not.exist;
|
|
281
|
+
expect(err).to.not.exist();
|
|
282
282
|
expect(value).to.deep.equal({ a: 22, b: 6 });
|
|
283
283
|
done();
|
|
284
284
|
});
|
|
@@ -293,7 +293,7 @@ describe('ref', function () {
|
|
|
293
293
|
|
|
294
294
|
Joi.validate({ a: 5, b: 6 }, schema, { context: { x: 22 } }, function (err, value) {
|
|
295
295
|
|
|
296
|
-
expect(err).to.exist;
|
|
296
|
+
expect(err).to.exist();
|
|
297
297
|
expect(err.message).to.equal('a must be one of context:x');
|
|
298
298
|
|
|
299
299
|
Helper.validateOptions(schema, [
|
|
@@ -353,7 +353,7 @@ describe('ref', function () {
|
|
|
353
353
|
it('describes schema with ref', function (done) {
|
|
354
354
|
|
|
355
355
|
var desc = Joi.compile(Joi.ref('a.b')).describe();
|
|
356
|
-
expect(Joi.isRef(desc.valids[0])).to.be.true;
|
|
356
|
+
expect(Joi.isRef(desc.valids[0])).to.be.true();
|
|
357
357
|
done();
|
|
358
358
|
});
|
|
359
359
|
|
package/test/string.js
CHANGED
|
@@ -295,7 +295,7 @@ describe('string', function () {
|
|
|
295
295
|
var schema = Joi.string().lowercase();
|
|
296
296
|
schema.validate('UPPER TO LOWER', function (err, value) {
|
|
297
297
|
|
|
298
|
-
expect(err).to.not.exist;
|
|
298
|
+
expect(err).to.not.exist();
|
|
299
299
|
expect(value).to.equal('upper to lower');
|
|
300
300
|
done();
|
|
301
301
|
});
|
|
@@ -333,7 +333,7 @@ describe('string', function () {
|
|
|
333
333
|
var schema = Joi.string().uppercase();
|
|
334
334
|
schema.validate('lower to upper', function (err, value) {
|
|
335
335
|
|
|
336
|
-
expect(err).to.not.exist;
|
|
336
|
+
expect(err).to.not.exist();
|
|
337
337
|
expect(value).to.equal('LOWER TO UPPER');
|
|
338
338
|
done();
|
|
339
339
|
});
|
|
@@ -370,7 +370,7 @@ describe('string', function () {
|
|
|
370
370
|
var schema = Joi.string().trim();
|
|
371
371
|
schema.validate(' trim this ', function (err, value) {
|
|
372
372
|
|
|
373
|
-
expect(err).to.not.exist;
|
|
373
|
+
expect(err).to.not.exist();
|
|
374
374
|
expect(value).to.equal('trim this');
|
|
375
375
|
done();
|
|
376
376
|
});
|
|
@@ -381,7 +381,7 @@ describe('string', function () {
|
|
|
381
381
|
var schema = Joi.string().trim().allow('');
|
|
382
382
|
schema.validate(' ', function (err, value) {
|
|
383
383
|
|
|
384
|
-
expect(err).to.not.exist;
|
|
384
|
+
expect(err).to.not.exist();
|
|
385
385
|
expect(value).to.equal('');
|
|
386
386
|
done();
|
|
387
387
|
});
|
|
@@ -650,7 +650,7 @@ describe('string', function () {
|
|
|
650
650
|
var text = Joi.string().invalid('joi');
|
|
651
651
|
text.validate('joi', function (err, value) {
|
|
652
652
|
|
|
653
|
-
expect(err).to.exist;
|
|
653
|
+
expect(err).to.exist();
|
|
654
654
|
done();
|
|
655
655
|
});
|
|
656
656
|
});
|
|
@@ -660,7 +660,7 @@ describe('string', function () {
|
|
|
660
660
|
var text = Joi.string().allow('hapi');
|
|
661
661
|
text.validate('result', function (err, value) {
|
|
662
662
|
|
|
663
|
-
expect(err).to.not.exist;
|
|
663
|
+
expect(err).to.not.exist();
|
|
664
664
|
done();
|
|
665
665
|
});
|
|
666
666
|
});
|
|
@@ -670,7 +670,7 @@ describe('string', function () {
|
|
|
670
670
|
var text = Joi.string().min(3);
|
|
671
671
|
text.validate('joi', function (err, value) {
|
|
672
672
|
|
|
673
|
-
expect(err).to.not.exist;
|
|
673
|
+
expect(err).to.not.exist();
|
|
674
674
|
done();
|
|
675
675
|
});
|
|
676
676
|
});
|
|
@@ -680,11 +680,11 @@ describe('string', function () {
|
|
|
680
680
|
var text = Joi.string().min(3).required();
|
|
681
681
|
text.validate('joi', function (err, value) {
|
|
682
682
|
|
|
683
|
-
expect(err).to.not.exist;
|
|
683
|
+
expect(err).to.not.exist();
|
|
684
684
|
|
|
685
685
|
text.validate('', function (err, value) {
|
|
686
686
|
|
|
687
|
-
expect(err).to.exist;
|
|
687
|
+
expect(err).to.exist();
|
|
688
688
|
done();
|
|
689
689
|
});
|
|
690
690
|
});
|