joi 4.6.2 → 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.
Files changed (66) hide show
  1. package/.c9/.nakignore +17 -0
  2. package/.c9/metadata/tab0 +1 -0
  3. package/.c9/metadata/workspace/.c9/project.settings +1 -0
  4. package/.c9/metadata/workspace/.travis.yml +1 -0
  5. package/.c9/metadata/workspace/Makefile +1 -0
  6. package/.c9/metadata/workspace/README.md +1 -0
  7. package/.c9/metadata/workspace/lib/any.js +1 -0
  8. package/.c9/metadata/workspace/lib/array.js +1 -0
  9. package/.c9/metadata/workspace/lib/binary.js +1 -0
  10. package/.c9/metadata/workspace/lib/boolean.js +1 -0
  11. package/.c9/metadata/workspace/lib/cast.js +1 -0
  12. package/.c9/metadata/workspace/lib/date.js +1 -0
  13. package/.c9/metadata/workspace/lib/errors.js +1 -0
  14. package/.c9/metadata/workspace/lib/function.js +1 -0
  15. package/.c9/metadata/workspace/lib/index.js +1 -0
  16. package/.c9/metadata/workspace/lib/language.js +1 -0
  17. package/.c9/metadata/workspace/lib/number.js +1 -0
  18. package/.c9/metadata/workspace/lib/object.js +1 -0
  19. package/.c9/metadata/workspace/lib/string.js +1 -0
  20. package/.c9/metadata/workspace/package.json +1 -0
  21. package/.c9/metadata/workspace/test/alternatives.js +1 -0
  22. package/.c9/metadata/workspace/test/any.js +1 -0
  23. package/.c9/metadata/workspace/test/array.js +1 -0
  24. package/.c9/metadata/workspace/test/binary.js +1 -0
  25. package/.c9/metadata/workspace/test/boolean.js +1 -0
  26. package/.c9/metadata/workspace/test/date.js +1 -0
  27. package/.c9/metadata/workspace/test/errors.js +1 -0
  28. package/.c9/metadata/workspace/test/function.js +1 -0
  29. package/.c9/metadata/workspace/test/helper.js +1 -0
  30. package/.c9/metadata/workspace/test/index.js +1 -0
  31. package/.c9/metadata/workspace/test/number.js +1 -0
  32. package/.c9/metadata/workspace/test/object.js +1 -0
  33. package/.c9/metadata/workspace/test/ref.js +1 -0
  34. package/.c9/metadata/workspace/test/string.js +1 -0
  35. package/.c9/project.settings +34 -0
  36. package/.travis.yml +1 -0
  37. package/Makefile +3 -3
  38. package/README.md +162 -31
  39. package/examples/conditionalRequire.js +43 -0
  40. package/examples/customMessage.js +22 -0
  41. package/examples/multipleWhen.js +17 -0
  42. package/lib/any.js +35 -24
  43. package/lib/array.js +25 -0
  44. package/lib/date.js +64 -9
  45. package/lib/errors.js +18 -2
  46. package/lib/index.js +3 -2
  47. package/lib/language.js +17 -6
  48. package/lib/number.js +50 -0
  49. package/lib/object.js +69 -5
  50. package/lib/string.js +27 -6
  51. package/package.json +5 -3
  52. package/test/alternatives.js +12 -10
  53. package/test/any.js +64 -15
  54. package/test/array.js +55 -16
  55. package/test/binary.js +13 -11
  56. package/test/boolean.js +9 -7
  57. package/test/date.js +143 -20
  58. package/test/errors.js +26 -15
  59. package/test/function.js +7 -5
  60. package/test/helper.js +7 -5
  61. package/test/index.js +116 -73
  62. package/test/number.js +125 -12
  63. package/test/object.js +192 -43
  64. package/test/ref.js +22 -20
  65. package/test/string.js +255 -106
  66. package/AUTHORS +0 -3
package/test/string.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // Load modules
2
2
 
3
3
  var Lab = require('lab');
4
+ var Code = require('code');
4
5
  var Joi = require('../lib');
5
6
  var Helper = require('./helper');
6
7
 
@@ -12,11 +13,12 @@ var internals = {};
12
13
 
13
14
  // Test shortcuts
14
15
 
15
- var expect = Lab.expect;
16
- var before = Lab.before;
17
- var after = Lab.after;
18
- var describe = Lab.experiment;
19
- var it = Lab.test;
16
+ var lab = exports.lab = Lab.script();
17
+ var before = lab.before;
18
+ var after = lab.after;
19
+ var describe = lab.describe;
20
+ var it = lab.it;
21
+ var expect = Code.expect;
20
22
 
21
23
 
22
24
  describe('string', function () {
@@ -185,6 +187,43 @@ describe('string', function () {
185
187
  });
186
188
  });
187
189
 
190
+ describe('#creditCard', function () {
191
+
192
+ it('should validate credit card', function (done) {
193
+
194
+ var t = Joi.string().creditCard();
195
+ t.validate('4111111111111112', function (err, value) {
196
+
197
+ expect(err.message).to.equal('value must be a credit card');
198
+
199
+ Helper.validate(t, [
200
+ ['378734493671000', true], // american express
201
+ ['371449635398431', true], // american express
202
+ ['378282246310005', true], // american express
203
+ ['341111111111111', true], // american express
204
+ ['5610591081018250', true], // australian bank
205
+ ['5019717010103742', true], // dankort pbs
206
+ ['38520000023237', true], // diners club
207
+ ['30569309025904', true], // diners club
208
+ ['6011000990139424', true], // discover
209
+ ['6011111111111117', true], // discover
210
+ ['6011601160116611', true], // discover
211
+ ['3566002020360505', true], // jbc
212
+ ['3530111333300000', true], // jbc
213
+ ['5105105105105100', true], // mastercard
214
+ ['5555555555554444', true], // mastercard
215
+ ['5431111111111111', true], // mastercard
216
+ ['6331101999990016', true], // switch/solo paymentech
217
+ ['4222222222222', true], // visa
218
+ ['4012888888881881', true], // visa
219
+ ['4111111111111111', true], // visa
220
+ ['4111111111111112', false],
221
+ [null, false],
222
+ ], done);
223
+ });
224
+ });
225
+ });
226
+
188
227
  describe('#length', function () {
189
228
 
190
229
  it('throws when limit is not a number', function (done) {
@@ -256,7 +295,7 @@ describe('string', function () {
256
295
  var schema = Joi.string().lowercase();
257
296
  schema.validate('UPPER TO LOWER', function (err, value) {
258
297
 
259
- expect(err).to.not.exist;
298
+ expect(err).to.not.exist();
260
299
  expect(value).to.equal('upper to lower');
261
300
  done();
262
301
  });
@@ -294,7 +333,7 @@ describe('string', function () {
294
333
  var schema = Joi.string().uppercase();
295
334
  schema.validate('lower to upper', function (err, value) {
296
335
 
297
- expect(err).to.not.exist;
336
+ expect(err).to.not.exist();
298
337
  expect(value).to.equal('LOWER TO UPPER');
299
338
  done();
300
339
  });
@@ -331,7 +370,7 @@ describe('string', function () {
331
370
  var schema = Joi.string().trim();
332
371
  schema.validate(' trim this ', function (err, value) {
333
372
 
334
- expect(err).to.not.exist;
373
+ expect(err).to.not.exist();
335
374
  expect(value).to.equal('trim this');
336
375
  done();
337
376
  });
@@ -342,7 +381,7 @@ describe('string', function () {
342
381
  var schema = Joi.string().trim().allow('');
343
382
  schema.validate(' ', function (err, value) {
344
383
 
345
- expect(err).to.not.exist;
384
+ expect(err).to.not.exist();
346
385
  expect(value).to.equal('');
347
386
  done();
348
387
  });
@@ -389,6 +428,29 @@ describe('string', function () {
389
428
  });
390
429
  });
391
430
 
431
+ describe('#regex', function () {
432
+
433
+ it('should not include a pattern name by default', function (done) {
434
+
435
+ var schema = Joi.string().regex(/[a-z]+/).regex(/[0-9]+/);
436
+ schema.validate('abcd', function (err, value) {
437
+
438
+ expect(err.message).to.contain('required pattern');
439
+ done();
440
+ });
441
+ });
442
+
443
+ it('should include a pattern name if specified', function (done) {
444
+
445
+ var schema = Joi.string().regex(/[a-z]+/, 'letters').regex(/[0-9]+/, 'numbers');
446
+ schema.validate('abcd', function (err, value) {
447
+
448
+ expect(err.message).to.contain('numbers pattern');
449
+ done();
450
+ });
451
+ });
452
+ });
453
+
392
454
  describe('#validate', function () {
393
455
 
394
456
  it('should, by default, allow undefined, deny empty string', function (done) {
@@ -427,7 +489,7 @@ describe('string', function () {
427
489
  ], done);
428
490
  });
429
491
 
430
- it('should validate invalid values', function (done) {
492
+ it('validates invalid values', function (done) {
431
493
 
432
494
  var schema = Joi.string().invalid('a', 'b', 'c');
433
495
  Helper.validate(schema, [
@@ -447,7 +509,7 @@ describe('string', function () {
447
509
  ], done);
448
510
  });
449
511
 
450
- it('should handle array arguments correctly', function (done) {
512
+ it('validates array arguments correctly', function (done) {
451
513
 
452
514
  var schema = Joi.string().valid(['a', 'b', 'c']);
453
515
  Helper.validate(schema, [
@@ -457,7 +519,7 @@ describe('string', function () {
457
519
  ], done);
458
520
  });
459
521
 
460
- it('should validate minimum length when min is used', function (done) {
522
+ it('validates minimum length when min is used', function (done) {
461
523
 
462
524
  var schema = Joi.string().min(3);
463
525
  Helper.validate(schema, [
@@ -467,7 +529,7 @@ describe('string', function () {
467
529
  ], done);
468
530
  });
469
531
 
470
- it('should validate minimum length when min is 0', function (done) {
532
+ it('validates minimum length when min is 0', function (done) {
471
533
 
472
534
  var schema = Joi.string().min(0).required();
473
535
  Helper.validate(schema, [
@@ -493,7 +555,7 @@ describe('string', function () {
493
555
  ], done);
494
556
  });
495
557
 
496
- it('should validate maximum length when max is used', function (done) {
558
+ it('validates maximum length when max is used', function (done) {
497
559
 
498
560
  var schema = Joi.string().max(3);
499
561
  Helper.validate(schema, [
@@ -522,7 +584,7 @@ describe('string', function () {
522
584
  ], done);
523
585
  });
524
586
 
525
- it('should validate regex', function (done) {
587
+ it('validates regex', function (done) {
526
588
 
527
589
  var schema = Joi.string().regex(/^[0-9][-][a-z]+$/);
528
590
  Helper.validate(schema, [
@@ -531,6 +593,15 @@ describe('string', function () {
531
593
  ], done);
532
594
  });
533
595
 
596
+ it('validates regex (ignoring global flag)', function (done) {
597
+
598
+ var schema = Joi.string().regex(/a/g);
599
+ Helper.validate(schema, [
600
+ ['ab', true],
601
+ ['ac', true]
602
+ ], done);
603
+ });
604
+
534
605
  it('validates token', function (done) {
535
606
 
536
607
  var schema = Joi.string().token();
@@ -551,7 +622,7 @@ describe('string', function () {
551
622
  ], done);
552
623
  });
553
624
 
554
- it('should validate email', function (done) {
625
+ it('validates email', function (done) {
555
626
 
556
627
  var schema = Joi.string().email();
557
628
  Helper.validate(schema, [
@@ -564,7 +635,7 @@ describe('string', function () {
564
635
  ], done);
565
636
  });
566
637
 
567
- it('should validate email with a friendly error message', function (done) {
638
+ it('validates email with a friendly error message', function (done) {
568
639
 
569
640
  var schema = { item: Joi.string().email() };
570
641
  Joi.compile(schema).validate({ item: 'something' }, function (err, value) {
@@ -579,7 +650,7 @@ describe('string', function () {
579
650
  var text = Joi.string().invalid('joi');
580
651
  text.validate('joi', function (err, value) {
581
652
 
582
- expect(err).to.exist;
653
+ expect(err).to.exist();
583
654
  done();
584
655
  });
585
656
  });
@@ -589,44 +660,44 @@ describe('string', function () {
589
660
  var text = Joi.string().allow('hapi');
590
661
  text.validate('result', function (err, value) {
591
662
 
592
- expect(err).to.not.exist;
663
+ expect(err).to.not.exist();
593
664
  done();
594
665
  });
595
666
  });
596
667
 
597
- it('should validate with one validator (min)', function (done) {
668
+ it('validates with one validator (min)', function (done) {
598
669
 
599
670
  var text = Joi.string().min(3);
600
671
  text.validate('joi', function (err, value) {
601
672
 
602
- expect(err).to.not.exist;
673
+ expect(err).to.not.exist();
603
674
  done();
604
675
  });
605
676
  });
606
677
 
607
- it('should validate with two validators (min, required)', function (done) {
678
+ it('validates with two validators (min, required)', function (done) {
608
679
 
609
680
  var text = Joi.string().min(3).required();
610
681
  text.validate('joi', function (err, value) {
611
682
 
612
- expect(err).to.not.exist;
683
+ expect(err).to.not.exist();
613
684
 
614
685
  text.validate('', function (err, value) {
615
686
 
616
- expect(err).to.exist;
687
+ expect(err).to.exist();
617
688
  done();
618
689
  });
619
690
  });
620
691
  });
621
692
 
622
- it('should validate null with allow(null)', function (done) {
693
+ it('validates null with allow(null)', function (done) {
623
694
 
624
695
  Helper.validate(Joi.string().allow(null), [
625
696
  [null, true]
626
697
  ], done);
627
698
  });
628
699
 
629
- it('should validate "" (empty string) with allow(\'\')', function (done) {
700
+ it('validates "" (empty string) with allow(\'\')', function (done) {
630
701
 
631
702
  Helper.validate(Joi.string().allow(''), [
632
703
  ['', true],
@@ -634,7 +705,7 @@ describe('string', function () {
634
705
  ], done);
635
706
  });
636
707
 
637
- it('should handle combination of required and min', function (done) {
708
+ it('validates combination of required and min', function (done) {
638
709
 
639
710
  var rule = Joi.string().required().min(3);
640
711
  Helper.validate(rule, [
@@ -645,7 +716,7 @@ describe('string', function () {
645
716
  ], done);
646
717
  });
647
718
 
648
- it('should handle combination of required and max', function (done) {
719
+ it('validates combination of required and max', function (done) {
649
720
 
650
721
  var rule = Joi.string().required().max(3);
651
722
  Helper.validate(rule, [
@@ -657,7 +728,7 @@ describe('string', function () {
657
728
  ], done);
658
729
  });
659
730
 
660
- it('should handle combination of allow(\'\') and min', function (done) {
731
+ it('validates combination of allow(\'\') and min', function (done) {
661
732
 
662
733
  var rule = Joi.string().allow('').min(3);
663
734
  Helper.validate(rule, [
@@ -669,7 +740,7 @@ describe('string', function () {
669
740
  ], done);
670
741
  });
671
742
 
672
- it('should handle combination of allow(\'\') and max', function (done) {
743
+ it('validates combination of allow(\'\') and max', function (done) {
673
744
 
674
745
  var rule = Joi.string().allow('').max(3);
675
746
  Helper.validate(rule, [
@@ -681,7 +752,7 @@ describe('string', function () {
681
752
  ], done);
682
753
  });
683
754
 
684
- it('should handle combination of null allowed and max', function (done) {
755
+ it('validates combination of null allowed and max', function (done) {
685
756
  var rule = Joi.string().allow(null).max(3);
686
757
  Helper.validate(rule, [
687
758
  ['x', true],
@@ -692,7 +763,7 @@ describe('string', function () {
692
763
  ], done);
693
764
  });
694
765
 
695
- it('should handle combination of min and max', function (done) {
766
+ it('validates combination of min and max', function (done) {
696
767
 
697
768
  var rule = Joi.string().min(2).max(3);
698
769
  Helper.validate(rule, [
@@ -705,7 +776,7 @@ describe('string', function () {
705
776
  ], done);
706
777
  });
707
778
 
708
- it('should handle combination of min, max, and allow(\'\')', function (done) {
779
+ it('validates combination of min, max, and allow(\'\')', function (done) {
709
780
 
710
781
  var rule = Joi.string().min(2).max(3).allow('');
711
782
  Helper.validate(rule, [
@@ -718,7 +789,7 @@ describe('string', function () {
718
789
  ], done);
719
790
  });
720
791
 
721
- it('should handle combination of min, max, and required', function (done) {
792
+ it('validates combination of min, max, and required', function (done) {
722
793
 
723
794
  var rule = Joi.string().min(2).max(3).required();
724
795
  Helper.validate(rule, [
@@ -731,7 +802,7 @@ describe('string', function () {
731
802
  ], done);
732
803
  });
733
804
 
734
- it('should handle combination of min, max, and regex', function (done) {
805
+ it('validates combination of min, max, and regex', function (done) {
735
806
 
736
807
  var rule = Joi.string().min(2).max(3).regex(/^a/);
737
808
  Helper.validate(rule, [
@@ -747,7 +818,7 @@ describe('string', function () {
747
818
  ], done);
748
819
  });
749
820
 
750
- it('should handle combination of min, max, regex, and allow(\'\')', function (done) {
821
+ it('validates combination of min, max, regex, and allow(\'\')', function (done) {
751
822
 
752
823
  var rule = Joi.string().min(2).max(3).regex(/^a/).allow('');
753
824
  Helper.validate(rule, [
@@ -763,7 +834,7 @@ describe('string', function () {
763
834
  ], done);
764
835
  });
765
836
 
766
- it('should handle combination of min, max, regex, and required', function (done) {
837
+ it('validates combination of min, max, regex, and required', function (done) {
767
838
 
768
839
  var rule = Joi.string().min(2).max(3).regex(/^a/).required();
769
840
  Helper.validate(rule, [
@@ -779,7 +850,7 @@ describe('string', function () {
779
850
  ], done);
780
851
  });
781
852
 
782
- it('should handle combination of min, max, and alphanum', function (done) {
853
+ it('validates combination of min, max, and alphanum', function (done) {
783
854
 
784
855
  var rule = Joi.string().min(2).max(3).alphanum();
785
856
  Helper.validate(rule, [
@@ -796,7 +867,7 @@ describe('string', function () {
796
867
  ], done);
797
868
  });
798
869
 
799
- it('should handle combination of min, max, alphanum, and allow(\'\')', function (done) {
870
+ it('validates combination of min, max, alphanum, and allow(\'\')', function (done) {
800
871
 
801
872
  var rule = Joi.string().min(2).max(3).alphanum().allow('');
802
873
  Helper.validate(rule, [
@@ -813,7 +884,7 @@ describe('string', function () {
813
884
  ], done);
814
885
  });
815
886
 
816
- it('should handle combination of min, max, alphanum, and required', function (done) {
887
+ it('validates combination of min, max, alphanum, and required', function (done) {
817
888
 
818
889
  var rule = Joi.string().min(2).max(3).alphanum().required();
819
890
  Helper.validate(rule, [
@@ -830,7 +901,7 @@ describe('string', function () {
830
901
  ], done);
831
902
  });
832
903
 
833
- it('should handle combination of min, max, alphanum, and regex', function (done) {
904
+ it('validates combination of min, max, alphanum, and regex', function (done) {
834
905
 
835
906
  var rule = Joi.string().min(2).max(3).alphanum().regex(/^a/);
836
907
  Helper.validate(rule, [
@@ -848,7 +919,7 @@ describe('string', function () {
848
919
  ], done);
849
920
  });
850
921
 
851
- it('should handle combination of min, max, alphanum, required, and regex', function (done) {
922
+ it('validates combination of min, max, alphanum, required, and regex', function (done) {
852
923
 
853
924
  var rule = Joi.string().min(2).max(3).alphanum().required().regex(/^a/);
854
925
  Helper.validate(rule, [
@@ -866,7 +937,7 @@ describe('string', function () {
866
937
  ], done);
867
938
  });
868
939
 
869
- it('should handle combination of min, max, alphanum, allow(\'\'), and regex', function (done) {
940
+ it('validates combination of min, max, alphanum, allow(\'\'), and regex', function (done) {
870
941
 
871
942
  var rule = Joi.string().min(2).max(3).alphanum().allow('').regex(/^a/);
872
943
  Helper.validate(rule, [
@@ -884,7 +955,7 @@ describe('string', function () {
884
955
  ], done);
885
956
  });
886
957
 
887
- it('should handle combination of email and min', function (done) {
958
+ it('validates combination of email and min', function (done) {
888
959
 
889
960
  var rule = Joi.string().email().min(8);
890
961
  Helper.validate(rule, [
@@ -895,7 +966,7 @@ describe('string', function () {
895
966
  ], done);
896
967
  });
897
968
 
898
- it('should handle combination of email, min, and max', function (done) {
969
+ it('validates combination of email, min, and max', function (done) {
899
970
 
900
971
  var rule = Joi.string().email().min(8).max(10);
901
972
  Helper.validate(rule, [
@@ -908,7 +979,7 @@ describe('string', function () {
908
979
  ], done);
909
980
  });
910
981
 
911
- it('should handle combination of email, min, max, and invalid', function (done) {
982
+ it('validates combination of email, min, max, and invalid', function (done) {
912
983
 
913
984
  var rule = Joi.string().email().min(8).max(10).invalid('123@x.com');
914
985
  Helper.validate(rule, [
@@ -921,7 +992,7 @@ describe('string', function () {
921
992
  ], done);
922
993
  });
923
994
 
924
- it('should handle combination of email, min, max, and allow', function (done) {
995
+ it('validates combination of email, min, max, and allow', function (done) {
925
996
 
926
997
  var rule = Joi.string().email().min(8).max(10).allow('x@x.com');
927
998
  Helper.validate(rule, [
@@ -934,7 +1005,7 @@ describe('string', function () {
934
1005
  ], done);
935
1006
  });
936
1007
 
937
- it('should handle combination of email, min, max, allow, and invalid', function (done) {
1008
+ it('validates combination of email, min, max, allow, and invalid', function (done) {
938
1009
 
939
1010
  var rule = Joi.string().email().min(8).max(10).allow('x@x.com').invalid('123@x.com');
940
1011
  Helper.validate(rule, [
@@ -947,7 +1018,7 @@ describe('string', function () {
947
1018
  ], done);
948
1019
  });
949
1020
 
950
- it('should handle combination of email, min, max, allow, invalid, and allow(\'\')', function (done) {
1021
+ it('validates combination of email, min, max, allow, invalid, and allow(\'\')', function (done) {
951
1022
 
952
1023
  var rule = Joi.string().email().min(8).max(10).allow('x@x.com').invalid('123@x.com').allow('');
953
1024
  Helper.validate(rule, [
@@ -960,7 +1031,7 @@ describe('string', function () {
960
1031
  ], done);
961
1032
  });
962
1033
 
963
- it('should handle combination of email, min, max, allow, and allow(\'\')', function (done) {
1034
+ it('validates combination of email, min, max, allow, and allow(\'\')', function (done) {
964
1035
 
965
1036
  var rule = Joi.string().email().min(8).max(10).allow('x@x.com').allow('');
966
1037
  Helper.validate(rule, [
@@ -973,7 +1044,7 @@ describe('string', function () {
973
1044
  ], done);
974
1045
  });
975
1046
 
976
- it('should handle combination of email, min, max, allow, invalid, and regex', function (done) {
1047
+ it('validates combination of email, min, max, allow, invalid, and regex', function (done) {
977
1048
 
978
1049
  var rule = Joi.string().email().min(8).max(10).allow('x@x.com').invalid('123@x.com').regex(/^1/);
979
1050
  Helper.validate(rule, [
@@ -986,7 +1057,7 @@ describe('string', function () {
986
1057
  ], done);
987
1058
  });
988
1059
 
989
- it('should handle combination of email, min, max, allow, invalid, regex, and allow(\'\')', function (done) {
1060
+ it('validates combination of email, min, max, allow, invalid, regex, and allow(\'\')', function (done) {
990
1061
 
991
1062
  var rule = Joi.string().email().min(8).max(10).allow('x@x.com').invalid('123@x.com').regex(/^1/).allow('');
992
1063
  Helper.validate(rule, [
@@ -999,7 +1070,7 @@ describe('string', function () {
999
1070
  ], done);
1000
1071
  });
1001
1072
 
1002
- it('should handle combination of email, min, max, and allow(\'\')', function (done) {
1073
+ it('validates combination of email, min, max, and allow(\'\')', function (done) {
1003
1074
 
1004
1075
  var rule = Joi.string().email().min(8).max(10).allow('');
1005
1076
  Helper.validate(rule, [
@@ -1012,7 +1083,7 @@ describe('string', function () {
1012
1083
  ], done);
1013
1084
  });
1014
1085
 
1015
- it('should handle combination of email, min, max, and regex', function (done) {
1086
+ it('validates combination of email, min, max, and regex', function (done) {
1016
1087
 
1017
1088
  var rule = Joi.string().email().min(8).max(10).regex(/^1234/);
1018
1089
  Helper.validate(rule, [
@@ -1025,7 +1096,7 @@ describe('string', function () {
1025
1096
  ], done);
1026
1097
  });
1027
1098
 
1028
- it('should handle combination of email, min, max, regex, and allow(\'\')', function (done) {
1099
+ it('validates combination of email, min, max, regex, and allow(\'\')', function (done) {
1029
1100
 
1030
1101
  var rule = Joi.string().email().min(8).max(10).regex(/^1234/).allow('');
1031
1102
  Helper.validate(rule, [
@@ -1038,7 +1109,7 @@ describe('string', function () {
1038
1109
  ], done);
1039
1110
  });
1040
1111
 
1041
- it('should handle combination of email, min, max, regex, and required', function (done) {
1112
+ it('validates combination of email, min, max, regex, and required', function (done) {
1042
1113
 
1043
1114
  var rule = Joi.string().email().min(8).max(10).regex(/^1234/).required();
1044
1115
  Helper.validate(rule, [
@@ -1051,24 +1122,31 @@ describe('string', function () {
1051
1122
  ], done);
1052
1123
  });
1053
1124
 
1054
- it('should validate isoDate', function (done) {
1125
+ it('validates isoDate', function (done) {
1055
1126
 
1056
1127
  Helper.validate(Joi.string().isoDate(), [
1057
1128
  ['2013-06-07T14:21:46.295Z', true],
1129
+ ['2013-06-07T14:21:46.295Z0', false],
1058
1130
  ['2013-06-07T14:21:46.295+07:00', true],
1131
+ ['2013-06-07T14:21:46.295+07:000', false],
1059
1132
  ['2013-06-07T14:21:46.295-07:00', true],
1060
1133
  ['2013-06-07T14:21:46Z', true],
1134
+ ['2013-06-07T14:21:46Z0', false],
1061
1135
  ['2013-06-07T14:21:46+07:00', true],
1062
1136
  ['2013-06-07T14:21:46-07:00', true],
1063
1137
  ['2013-06-07T14:21Z', true],
1064
1138
  ['2013-06-07T14:21+07:00', true],
1139
+ ['2013-06-07T14:21+07:000', false],
1065
1140
  ['2013-06-07T14:21-07:00', true],
1066
1141
  ['2013-06-07T14:21Z+7:00', false],
1142
+ ['2013-06-07', true],
1143
+ ['2013-06-07T', false],
1144
+ ['2013-06-07T14:21', false],
1067
1145
  ['1-1-2013', false]
1068
1146
  ], done);
1069
1147
  });
1070
1148
 
1071
- it('should validate isoDate with a friendly error message', function (done) {
1149
+ it('validates isoDate with a friendly error message', function (done) {
1072
1150
 
1073
1151
  var schema = { item: Joi.string().isoDate() };
1074
1152
  Joi.compile(schema).validate({ item: 'something' }, function (err, value) {
@@ -1078,287 +1156,358 @@ describe('string', function () {
1078
1156
  });
1079
1157
  });
1080
1158
 
1081
- it('should handle combination of isoDate and min', function (done) {
1159
+ it('validates combination of isoDate and min', function (done) {
1082
1160
 
1083
1161
  var rule = Joi.string().isoDate().min(23);
1084
1162
  Helper.validate(rule, [
1085
1163
  ['2013-06-07T14:21:46.295Z', true],
1164
+ ['2013-06-07T14:21:46.295Z0', false],
1086
1165
  ['2013-06-07T14:21:46.295+07:00', true],
1166
+ ['2013-06-07T14:21:46.295+07:000', false],
1087
1167
  ['2013-06-07T14:21:46.295-07:00', true],
1088
1168
  ['2013-06-07T14:21:46Z', false],
1169
+ ['2013-06-07T14:21:46Z0', false],
1089
1170
  ['2013-06-07T14:21:46+07:00', true],
1090
1171
  ['2013-06-07T14:21:46-07:00', true],
1091
1172
  ['2013-06-07T14:21Z', false],
1092
1173
  ['2013-06-07T14:21+07:00', false],
1174
+ ['2013-06-07T14:21+07:000', false],
1093
1175
  ['2013-06-07T14:21-07:00', false],
1094
1176
  ['2013-06-07T14:21Z+7:00', false],
1177
+ ['2013-06-07', false],
1178
+ ['2013-06-07T', false],
1179
+ ['2013-06-07T14:21', false],
1095
1180
  ['1-1-2013', false],
1096
1181
  ['', false],
1097
1182
  [null, false]
1098
1183
  ], done);
1099
1184
  });
1100
1185
 
1101
- it('should handle combination of isoDate, min and max', function (done) {
1102
-
1103
- var rule = Joi.string().isoDate().min(17).max(23);
1104
- Helper.validate(rule, [
1105
- ['2013-06-07T14:21:46.295Z', false],
1106
- ['2013-06-07T14:21:46.295+07:00', false],
1107
- ['2013-06-07T14:21:46.295-07:00', false],
1108
- ['2013-06-07T14:21:46Z', true],
1109
- ['2013-06-07T14:21:46+07:00', false],
1110
- ['2013-06-07T14:21:46-07:00', false],
1111
- ['2013-06-07T14:21Z', true],
1112
- ['2013-06-07T14:21+07:00', true],
1113
- ['2013-06-07T14:21-07:00', true],
1114
- ['2013-06-07T14:21Z+7:00', false],
1115
- ['1-1-2013', false],
1116
- ['', false],
1117
- [null, false]
1118
- ], done);
1119
- });
1120
-
1121
- it('should handle combination of isoDate, min and max', function (done) {
1186
+ it('validates combination of isoDate, min and max', function (done) {
1122
1187
 
1123
1188
  var rule = Joi.string().isoDate().min(17).max(23);
1124
1189
  Helper.validate(rule, [
1125
1190
  ['2013-06-07T14:21:46.295Z', false],
1191
+ ['2013-06-07T14:21:46.295Z0', false],
1126
1192
  ['2013-06-07T14:21:46.295+07:00', false],
1193
+ ['2013-06-07T14:21:46.295+07:000', false],
1127
1194
  ['2013-06-07T14:21:46.295-07:00', false],
1128
1195
  ['2013-06-07T14:21:46Z', true],
1196
+ ['2013-06-07T14:21:46Z0', false],
1129
1197
  ['2013-06-07T14:21:46+07:00', false],
1130
1198
  ['2013-06-07T14:21:46-07:00', false],
1131
1199
  ['2013-06-07T14:21Z', true],
1132
1200
  ['2013-06-07T14:21+07:00', true],
1201
+ ['2013-06-07T14:21+07:000', false],
1133
1202
  ['2013-06-07T14:21-07:00', true],
1134
1203
  ['2013-06-07T14:21Z+7:00', false],
1204
+ ['2013-06-07', false],
1205
+ ['2013-06-07T', false],
1206
+ ['2013-06-07T14:21', false],
1135
1207
  ['1-1-2013', false],
1136
1208
  ['', false],
1137
1209
  [null, false]
1138
1210
  ], done);
1139
1211
  });
1140
1212
 
1141
- it('should handle combination of isoDate, min, max and invalid', function (done) {
1213
+ it('validates combination of isoDate, min, max and invalid', function (done) {
1142
1214
 
1143
1215
  var rule = Joi.string().isoDate().min(17).max(23).invalid('2013-06-07T14:21+07:00');
1144
1216
  Helper.validate(rule, [
1145
1217
  ['2013-06-07T14:21:46.295Z', false],
1218
+ ['2013-06-07T14:21:46.295Z0', false],
1146
1219
  ['2013-06-07T14:21:46.295+07:00', false],
1220
+ ['2013-06-07T14:21:46.295+07:000', false],
1147
1221
  ['2013-06-07T14:21:46.295-07:00', false],
1148
1222
  ['2013-06-07T14:21:46Z', true],
1223
+ ['2013-06-07T14:21:46Z0', false],
1149
1224
  ['2013-06-07T14:21:46+07:00', false],
1150
1225
  ['2013-06-07T14:21:46-07:00', false],
1151
1226
  ['2013-06-07T14:21Z', true],
1152
1227
  ['2013-06-07T14:21+07:00', false],
1228
+ ['2013-06-07T14:21+07:000', false],
1153
1229
  ['2013-06-07T14:21-07:00', true],
1154
1230
  ['2013-06-07T14:21Z+7:00', false],
1231
+ ['2013-06-07', false],
1232
+ ['2013-06-07T', false],
1233
+ ['2013-06-07T14:21', false],
1155
1234
  ['1-1-2013', false],
1156
1235
  ['', false],
1157
1236
  [null, false]
1158
1237
  ], done);
1159
1238
  });
1160
1239
 
1161
- it('should handle combination of isoDate, min, max and allow', function (done) {
1240
+ it('validates combination of isoDate, min, max and allow', function (done) {
1162
1241
 
1163
1242
  var rule = Joi.string().isoDate().min(17).max(23).allow('2013-06-07T14:21:46.295+07:00');
1164
1243
  Helper.validate(rule, [
1165
1244
  ['2013-06-07T14:21:46.295Z', false],
1245
+ ['2013-06-07T14:21:46.295Z0', false],
1166
1246
  ['2013-06-07T14:21:46.295+07:00', true],
1247
+ ['2013-06-07T14:21:46.295+07:000', false],
1167
1248
  ['2013-06-07T14:21:46.295-07:00', false],
1168
1249
  ['2013-06-07T14:21:46Z', true],
1250
+ ['2013-06-07T14:21:46Z0', false],
1169
1251
  ['2013-06-07T14:21:46+07:00', false],
1170
1252
  ['2013-06-07T14:21:46-07:00', false],
1171
1253
  ['2013-06-07T14:21Z', true],
1172
1254
  ['2013-06-07T14:21+07:00', true],
1255
+ ['2013-06-07T14:21+07:000', false],
1173
1256
  ['2013-06-07T14:21-07:00', true],
1174
1257
  ['2013-06-07T14:21Z+7:00', false],
1258
+ ['2013-06-07', false],
1259
+ ['2013-06-07T', false],
1260
+ ['2013-06-07T14:21', false],
1175
1261
  ['1-1-2013', false],
1176
1262
  ['', false],
1177
1263
  [null, false]
1178
1264
  ], done);
1179
1265
  });
1180
1266
 
1181
- it('should handle combination of isoDate, min, max, allow and invalid', function (done) {
1267
+ it('validates combination of isoDate, min, max, allow and invalid', function (done) {
1182
1268
 
1183
1269
  var rule = Joi.string().isoDate().min(17).max(23).allow('2013-06-07T14:21:46.295+07:00').invalid('2013-06-07T14:21+07:00');
1184
1270
  Helper.validate(rule, [
1185
1271
  ['2013-06-07T14:21:46.295Z', false],
1272
+ ['2013-06-07T14:21:46.295Z0', false],
1186
1273
  ['2013-06-07T14:21:46.295+07:00', true],
1274
+ ['2013-06-07T14:21:46.295+07:000', false],
1187
1275
  ['2013-06-07T14:21:46.295-07:00', false],
1188
1276
  ['2013-06-07T14:21:46Z', true],
1277
+ ['2013-06-07T14:21:46Z0', false],
1189
1278
  ['2013-06-07T14:21:46+07:00', false],
1190
1279
  ['2013-06-07T14:21:46-07:00', false],
1191
1280
  ['2013-06-07T14:21Z', true],
1192
1281
  ['2013-06-07T14:21+07:00', false],
1282
+ ['2013-06-07T14:21+07:000', false],
1193
1283
  ['2013-06-07T14:21-07:00', true],
1194
1284
  ['2013-06-07T14:21Z+7:00', false],
1285
+ ['2013-06-07', false],
1286
+ ['2013-06-07T', false],
1287
+ ['2013-06-07T14:21', false],
1195
1288
  ['1-1-2013', false],
1196
1289
  ['', false],
1197
1290
  [null, false]
1198
1291
  ], done);
1199
1292
  });
1200
1293
 
1201
- it('should handle combination of isoDate, min, max, allow, invalid and allow(\'\')', function (done) {
1294
+ it('validates combination of isoDate, min, max, allow, invalid and allow(\'\')', function (done) {
1202
1295
 
1203
1296
  var rule = Joi.string().isoDate().min(17).max(23).allow('2013-06-07T14:21:46.295+07:00').invalid('2013-06-07T14:21+07:00').allow('');
1204
1297
  Helper.validate(rule, [
1205
1298
  ['2013-06-07T14:21:46.295Z', false],
1299
+ ['2013-06-07T14:21:46.295Z0', false],
1206
1300
  ['2013-06-07T14:21:46.295+07:00', true],
1301
+ ['2013-06-07T14:21:46.295+07:000', false],
1207
1302
  ['2013-06-07T14:21:46.295-07:00', false],
1208
1303
  ['2013-06-07T14:21:46Z', true],
1304
+ ['2013-06-07T14:21:46Z0', false],
1209
1305
  ['2013-06-07T14:21:46+07:00', false],
1210
1306
  ['2013-06-07T14:21:46-07:00', false],
1211
1307
  ['2013-06-07T14:21Z', true],
1212
1308
  ['2013-06-07T14:21+07:00', false],
1309
+ ['2013-06-07T14:21+07:000', false],
1213
1310
  ['2013-06-07T14:21-07:00', true],
1214
1311
  ['2013-06-07T14:21Z+7:00', false],
1312
+ ['2013-06-07', false],
1313
+ ['2013-06-07T', false],
1314
+ ['2013-06-07T14:21', false],
1215
1315
  ['1-1-2013', false],
1216
1316
  ['', true],
1217
1317
  [null, false]
1218
1318
  ], done);
1219
1319
  });
1220
1320
 
1221
- it('should handle combination of isoDate, min, max, allow, invalid and allow(\'\')', function (done) {
1321
+ it('validates combination of isoDate, min, max, allow, invalid and allow(\'\')', function (done) {
1222
1322
 
1223
1323
  var rule = Joi.string().isoDate().min(17).max(23).allow('2013-06-07T14:21:46.295+07:00').allow('');
1224
1324
  Helper.validate(rule, [
1225
1325
  ['2013-06-07T14:21:46.295Z', false],
1326
+ ['2013-06-07T14:21:46.295Z0', false],
1226
1327
  ['2013-06-07T14:21:46.295+07:00', true],
1328
+ ['2013-06-07T14:21:46.295+07:000', false],
1227
1329
  ['2013-06-07T14:21:46.295-07:00', false],
1228
1330
  ['2013-06-07T14:21:46Z', true],
1331
+ ['2013-06-07T14:21:46Z0', false],
1229
1332
  ['2013-06-07T14:21:46+07:00', false],
1230
1333
  ['2013-06-07T14:21:46-07:00', false],
1231
1334
  ['2013-06-07T14:21Z', true],
1232
1335
  ['2013-06-07T14:21+07:00', true],
1336
+ ['2013-06-07T14:21+07:000', false],
1233
1337
  ['2013-06-07T14:21-07:00', true],
1234
1338
  ['2013-06-07T14:21Z+7:00', false],
1339
+ ['2013-06-07', false],
1340
+ ['2013-06-07T', false],
1341
+ ['2013-06-07T14:21', false],
1235
1342
  ['1-1-2013', false],
1236
1343
  ['', true],
1237
1344
  [null, false]
1238
1345
  ], done);
1239
1346
  });
1240
1347
 
1241
- it('should handle combination of isoDate, min, max, allow, invalid and regex', function (done) {
1348
+ it('validates combination of isoDate, min, max, allow, invalid and regex', function (done) {
1242
1349
 
1243
1350
  var rule = Joi.string().isoDate().min(17).max(23).allow('2013-06-07T14:21:46.295+07:00').invalid('2013-06-07T14:21Z').regex(/Z$/);
1244
1351
  Helper.validate(rule, [
1245
1352
  ['2013-06-07T14:21:46.295Z', false],
1353
+ ['2013-06-07T14:21:46.295Z0', false],
1246
1354
  ['2013-06-07T14:21:46.295+07:00', true],
1355
+ ['2013-06-07T14:21:46.295+07:000', false],
1247
1356
  ['2013-06-07T14:21:46.295-07:00', false],
1248
1357
  ['2013-06-07T14:21:46Z', true],
1358
+ ['2013-06-07T14:21:46Z0', false],
1249
1359
  ['2013-06-07T14:21:46+07:00', false],
1250
1360
  ['2013-06-07T14:21:46-07:00', false],
1251
1361
  ['2013-06-07T14:21Z', false],
1252
1362
  ['2013-06-07T14:21+07:00', false],
1363
+ ['2013-06-07T14:21+07:000', false],
1253
1364
  ['2013-06-07T14:21-07:00', false],
1254
1365
  ['2013-06-07T14:21Z+7:00', false],
1366
+ ['2013-06-07', false],
1367
+ ['2013-06-07T', false],
1368
+ ['2013-06-07T14:21', false],
1255
1369
  ['1-1-2013', false],
1256
1370
  ['', false],
1257
1371
  [null, false]
1258
1372
  ], done);
1259
1373
  });
1260
1374
 
1261
- it('should handle combination of isoDate, min, max, allow, invalid, regex and allow(\'\')', function (done) {
1375
+ it('validates combination of isoDate, min, max, allow, invalid, regex and allow(\'\')', function (done) {
1262
1376
 
1263
1377
  var rule = Joi.string().isoDate().min(17).max(23).allow('2013-06-07T14:21:46.295+07:00').invalid('2013-06-07T14:21Z').regex(/Z$/).allow('');
1264
1378
  Helper.validate(rule, [
1265
1379
  ['2013-06-07T14:21:46.295Z', false],
1380
+ ['2013-06-07T14:21:46.295Z0', false],
1266
1381
  ['2013-06-07T14:21:46.295+07:00', true],
1382
+ ['2013-06-07T14:21:46.295+07:000', false],
1267
1383
  ['2013-06-07T14:21:46.295-07:00', false],
1268
1384
  ['2013-06-07T14:21:46Z', true],
1385
+ ['2013-06-07T14:21:46Z0', false],
1269
1386
  ['2013-06-07T14:21:46+07:00', false],
1270
1387
  ['2013-06-07T14:21:46-07:00', false],
1271
1388
  ['2013-06-07T14:21Z', false],
1272
1389
  ['2013-06-07T14:21+07:00', false],
1390
+ ['2013-06-07T14:21+07:000', false],
1273
1391
  ['2013-06-07T14:21-07:00', false],
1274
1392
  ['2013-06-07T14:21Z+7:00', false],
1393
+ ['2013-06-07', false],
1394
+ ['2013-06-07T', false],
1395
+ ['2013-06-07T14:21', false],
1275
1396
  ['1-1-2013', false],
1276
1397
  ['', true],
1277
1398
  [null, false]
1278
1399
  ], done);
1279
1400
  });
1280
1401
 
1281
- it('should handle combination of isoDate, min, max and allow(\'\')', function (done) {
1402
+ it('validates combination of isoDate, min, max and allow(\'\')', function (done) {
1282
1403
 
1283
1404
  var rule = Joi.string().isoDate().min(17).max(23).allow('');
1284
1405
  Helper.validate(rule, [
1285
1406
  ['2013-06-07T14:21:46.295Z', false],
1407
+ ['2013-06-07T14:21:46.295Z0', false],
1286
1408
  ['2013-06-07T14:21:46.295+07:00', false],
1409
+ ['2013-06-07T14:21:46.295+07:000', false],
1287
1410
  ['2013-06-07T14:21:46.295-07:00', false],
1288
1411
  ['2013-06-07T14:21:46Z', true],
1412
+ ['2013-06-07T14:21:46Z0', false],
1289
1413
  ['2013-06-07T14:21:46+07:00', false],
1290
1414
  ['2013-06-07T14:21:46-07:00', false],
1291
1415
  ['2013-06-07T14:21Z', true],
1292
1416
  ['2013-06-07T14:21+07:00', true],
1417
+ ['2013-06-07T14:21+07:000', false],
1293
1418
  ['2013-06-07T14:21-07:00', true],
1294
1419
  ['2013-06-07T14:21Z+7:00', false],
1420
+ ['2013-06-07', false],
1421
+ ['2013-06-07T', false],
1422
+ ['2013-06-07T14:21', false],
1295
1423
  ['1-1-2013', false],
1296
1424
  ['', true],
1297
1425
  [null, false]
1298
1426
  ], done);
1299
1427
  });
1300
1428
 
1301
- it('should handle combination of isoDate, min, max and regex', function (done) {
1429
+ it('validates combination of isoDate, min, max and regex', function (done) {
1302
1430
 
1303
1431
  var rule = Joi.string().isoDate().min(17).max(23).regex(/Z$/);
1304
1432
  Helper.validate(rule, [
1305
1433
  ['2013-06-07T14:21:46.295Z', false],
1434
+ ['2013-06-07T14:21:46.295Z0', false],
1306
1435
  ['2013-06-07T14:21:46.295+07:00', false],
1436
+ ['2013-06-07T14:21:46.295+07:000', false],
1307
1437
  ['2013-06-07T14:21:46.295-07:00', false],
1308
1438
  ['2013-06-07T14:21:46Z', true],
1439
+ ['2013-06-07T14:21:46Z0', false],
1309
1440
  ['2013-06-07T14:21:46+07:00', false],
1310
1441
  ['2013-06-07T14:21:46-07:00', false],
1311
1442
  ['2013-06-07T14:21Z', true],
1312
1443
  ['2013-06-07T14:21+07:00', false],
1444
+ ['2013-06-07T14:21+07:000', false],
1313
1445
  ['2013-06-07T14:21-07:00', false],
1314
1446
  ['2013-06-07T14:21Z+7:00', false],
1447
+ ['2013-06-07', false],
1448
+ ['2013-06-07T', false],
1449
+ ['2013-06-07T14:21', false],
1315
1450
  ['1-1-2013', false],
1316
1451
  ['', false],
1317
1452
  [null, false]
1318
1453
  ], done);
1319
1454
  });
1320
1455
 
1321
- it('should handle combination of isoDate, min, max, regex and allow(\'\')', function (done) {
1456
+ it('validates combination of isoDate, min, max, regex and allow(\'\')', function (done) {
1322
1457
 
1323
1458
  var rule = Joi.string().isoDate().min(17).max(23).regex(/Z$/).allow('');
1324
1459
  Helper.validate(rule, [
1325
1460
  ['2013-06-07T14:21:46.295Z', false],
1461
+ ['2013-06-07T14:21:46.295Z0', false],
1326
1462
  ['2013-06-07T14:21:46.295+07:00', false],
1463
+ ['2013-06-07T14:21:46.295+07:000', false],
1327
1464
  ['2013-06-07T14:21:46.295-07:00', false],
1328
1465
  ['2013-06-07T14:21:46Z', true],
1466
+ ['2013-06-07T14:21:46Z0', false],
1329
1467
  ['2013-06-07T14:21:46+07:00', false],
1330
1468
  ['2013-06-07T14:21:46-07:00', false],
1331
1469
  ['2013-06-07T14:21Z', true],
1332
1470
  ['2013-06-07T14:21+07:00', false],
1471
+ ['2013-06-07T14:21+07:000', false],
1333
1472
  ['2013-06-07T14:21-07:00', false],
1334
1473
  ['2013-06-07T14:21Z+7:00', false],
1474
+ ['2013-06-07', false],
1475
+ ['2013-06-07T', false],
1476
+ ['2013-06-07T14:21', false],
1335
1477
  ['1-1-2013', false],
1336
1478
  ['', true],
1337
1479
  [null, false]
1338
1480
  ], done);
1339
1481
  });
1340
1482
 
1341
- it('should handle combination of isoDate, min, max, regex and required', function (done) {
1483
+ it('validates combination of isoDate, min, max, regex and required', function (done) {
1342
1484
 
1343
1485
  var rule = Joi.string().isoDate().min(17).max(23).regex(/Z$/).required();
1344
1486
  Helper.validate(rule, [
1345
1487
  ['2013-06-07T14:21:46.295Z', false],
1488
+ ['2013-06-07T14:21:46.295Z0', false],
1346
1489
  ['2013-06-07T14:21:46.295+07:00', false],
1490
+ ['2013-06-07T14:21:46.295+07:000', false],
1347
1491
  ['2013-06-07T14:21:46.295-07:00', false],
1348
1492
  ['2013-06-07T14:21:46Z', true],
1493
+ ['2013-06-07T14:21:46Z0', false],
1349
1494
  ['2013-06-07T14:21:46+07:00', false],
1350
1495
  ['2013-06-07T14:21:46-07:00', false],
1351
1496
  ['2013-06-07T14:21Z', true],
1352
1497
  ['2013-06-07T14:21+07:00', false],
1498
+ ['2013-06-07T14:21+07:000', false],
1353
1499
  ['2013-06-07T14:21-07:00', false],
1354
1500
  ['2013-06-07T14:21Z+7:00', false],
1501
+ ['2013-06-07', false],
1502
+ ['2013-06-07T', false],
1503
+ ['2013-06-07T14:21', false],
1355
1504
  ['1-1-2013', false],
1356
1505
  ['', false],
1357
1506
  [null, false]
1358
1507
  ], done);
1359
1508
  });
1360
1509
 
1361
- it('should validate guid', function (done) {
1510
+ it('validates guid', function (done) {
1362
1511
 
1363
1512
  Helper.validate(Joi.string().guid(), [
1364
1513
  ['{D1A5279D-B27D-4CD4-A05E-EFDD53D08E8D}', true],
@@ -1375,7 +1524,7 @@ describe('string', function () {
1375
1524
  ], done);
1376
1525
  });
1377
1526
 
1378
- it('should validate guid with a friendly error message', function (done) {
1527
+ it('validates guid with a friendly error message', function (done) {
1379
1528
 
1380
1529
  var schema = { item: Joi.string().guid() };
1381
1530
  Joi.compile(schema).validate({ item: 'something' }, function (err, value) {
@@ -1385,7 +1534,7 @@ describe('string', function () {
1385
1534
  });
1386
1535
  });
1387
1536
 
1388
- it('should handle combination of guid and min', function (done) {
1537
+ it('validates combination of guid and min', function (done) {
1389
1538
 
1390
1539
  var rule = Joi.string().guid().min(36);
1391
1540
  Helper.validate(rule, [
@@ -1405,7 +1554,7 @@ describe('string', function () {
1405
1554
  ], done);
1406
1555
  });
1407
1556
 
1408
- it('should handle combination of guid, min and max', function (done) {
1557
+ it('validates combination of guid, min and max', function (done) {
1409
1558
 
1410
1559
  var rule = Joi.string().guid().min(32).max(34);
1411
1560
  Helper.validate(rule, [
@@ -1425,7 +1574,7 @@ describe('string', function () {
1425
1574
  ], done);
1426
1575
  });
1427
1576
 
1428
- it('should handle combination of guid, min, max and invalid', function (done) {
1577
+ it('validates combination of guid, min, max and invalid', function (done) {
1429
1578
 
1430
1579
  var rule = Joi.string().guid().min(32).max(34).invalid('b4b2fb69c6244e5eb0698e0c6ec66618');
1431
1580
  Helper.validate(rule, [
@@ -1445,7 +1594,7 @@ describe('string', function () {
1445
1594
  ], done);
1446
1595
  });
1447
1596
 
1448
- it('should handle combination of guid, min, max and allow', function (done) {
1597
+ it('validates combination of guid, min, max and allow', function (done) {
1449
1598
 
1450
1599
  var rule = Joi.string().guid().min(32).max(34).allow('{D1A5279D-B27D-4CD4-A05E-EFDD53D08E8D');
1451
1600
  Helper.validate(rule, [
@@ -1465,7 +1614,7 @@ describe('string', function () {
1465
1614
  ], done);
1466
1615
  });
1467
1616
 
1468
- it('should handle combination of guid, min, max, allow and invalid', function (done) {
1617
+ it('validates combination of guid, min, max, allow and invalid', function (done) {
1469
1618
 
1470
1619
  var rule = Joi.string().guid().min(32).max(34).allow('{D1A5279D-B27D-4CD4-A05E-EFDD53D08E8D').invalid('b4b2fb69c6244e5eb0698e0c6ec66618');
1471
1620
  Helper.validate(rule, [
@@ -1485,7 +1634,7 @@ describe('string', function () {
1485
1634
  ], done);
1486
1635
  });
1487
1636
 
1488
- it('should handle combination of guid, min, max, allow, invalid and allow(\'\')', function (done) {
1637
+ it('validates combination of guid, min, max, allow, invalid and allow(\'\')', function (done) {
1489
1638
 
1490
1639
  var rule = Joi.string().guid().min(32).max(34).allow('{D1A5279D-B27D-4CD4-A05E-EFDD53D08E8D').invalid('b4b2fb69c6244e5eb0698e0c6ec66618').allow('');
1491
1640
  Helper.validate(rule, [
@@ -1505,7 +1654,7 @@ describe('string', function () {
1505
1654
  ], done);
1506
1655
  });
1507
1656
 
1508
- it('should handle combination of guid, min, max, allow and allow(\'\')', function (done) {
1657
+ it('validates combination of guid, min, max, allow and allow(\'\')', function (done) {
1509
1658
 
1510
1659
  var rule = Joi.string().guid().min(32).max(34).allow('{D1A5279D-B27D-4CD4-A05E-EFDD53D08E8D').allow('');
1511
1660
  Helper.validate(rule, [
@@ -1525,7 +1674,7 @@ describe('string', function () {
1525
1674
  ], done);
1526
1675
  });
1527
1676
 
1528
- it('should handle combination of guid, min, max, allow, invalid and regex', function (done) {
1677
+ it('validates combination of guid, min, max, allow, invalid and regex', function (done) {
1529
1678
 
1530
1679
  var rule = Joi.string().guid().min(32).max(34).allow('{D1A5279D-B27D-4CD4-A05E-EFDD53D08').invalid('b4b2fb69c6244e5eb0698e0c6ec66618').regex(/^{7e908/);
1531
1680
  Helper.validate(rule, [
@@ -1545,7 +1694,7 @@ describe('string', function () {
1545
1694
  ], done);
1546
1695
  });
1547
1696
 
1548
- it('should handle combination of guid, min, max, allow, invalid, regex and allow(\'\')', function (done) {
1697
+ it('validates combination of guid, min, max, allow, invalid, regex and allow(\'\')', function (done) {
1549
1698
 
1550
1699
  var rule = Joi.string().guid().min(32).max(34).allow('{D1A5279D-B27D-4CD4-A05E-EFDD53D08').invalid('b4b2fb69c6244e5eb0698e0c6ec66618').regex(/^{7e908/).allow('');
1551
1700
  Helper.validate(rule, [
@@ -1565,7 +1714,7 @@ describe('string', function () {
1565
1714
  ], done);
1566
1715
  });
1567
1716
 
1568
- it('should handle combination of guid, min, max and allow(\'\')', function (done) {
1717
+ it('validates combination of guid, min, max and allow(\'\')', function (done) {
1569
1718
 
1570
1719
  var rule = Joi.string().guid().min(32).max(34).allow('');
1571
1720
  Helper.validate(rule, [
@@ -1585,7 +1734,7 @@ describe('string', function () {
1585
1734
  ], done);
1586
1735
  });
1587
1736
 
1588
- it('should handle combination of guid, min, max and regex', function (done) {
1737
+ it('validates combination of guid, min, max and regex', function (done) {
1589
1738
 
1590
1739
  var rule = Joi.string().guid().min(32).max(34).regex(/^{7e9081/i);
1591
1740
  Helper.validate(rule, [
@@ -1605,7 +1754,7 @@ describe('string', function () {
1605
1754
  ], done);
1606
1755
  });
1607
1756
 
1608
- it('should handle combination of guid, min, max, regex and allow(\'\')', function (done) {
1757
+ it('validates combination of guid, min, max, regex and allow(\'\')', function (done) {
1609
1758
 
1610
1759
  var rule = Joi.string().guid().min(32).max(34).regex(/^{7e9081/i).allow('');
1611
1760
  Helper.validate(rule, [
@@ -1625,7 +1774,7 @@ describe('string', function () {
1625
1774
  ], done);
1626
1775
  });
1627
1776
 
1628
- it('should handle combination of guid, min, max, regex and required', function (done) {
1777
+ it('validates combination of guid, min, max, regex and required', function (done) {
1629
1778
 
1630
1779
  var rule = Joi.string().guid().min(32).max(34).regex(/^{7e9081/i).required();
1631
1780
  Helper.validate(rule, [