@@ -388,7 +388,7 @@ describe('Validator', function () {
388
388
expected : 'string' ,
389
389
actual : 'number' ,
390
390
message : 'must be of string type' ,
391
- property : 'arr.2 '
391
+ property : 'arr.0 '
392
392
} ,
393
393
{
394
394
attribute : 'type' ,
@@ -402,7 +402,7 @@ describe('Validator', function () {
402
402
expected : 'string' ,
403
403
actual : 'number' ,
404
404
message : 'must be of string type' ,
405
- property : 'arr.0 '
405
+ property : 'arr.2 '
406
406
}
407
407
] ) ;
408
408
@@ -477,7 +477,7 @@ describe('Validator', function () {
477
477
expect ( result . errors ) . toEqual ( [
478
478
{
479
479
attribute : 'type' ,
480
- property : '2 ' ,
480
+ property : '0 ' ,
481
481
expected : 'string' ,
482
482
actual : 'number' ,
483
483
message : 'must be of string type'
@@ -491,7 +491,7 @@ describe('Validator', function () {
491
491
} ,
492
492
{
493
493
attribute : 'type' ,
494
- property : '0 ' ,
494
+ property : '2 ' ,
495
495
expected : 'string' ,
496
496
actual : 'number' ,
497
497
message : 'must be of string type'
@@ -514,8 +514,8 @@ describe('Validator', function () {
514
514
var result = val . validate ( { arr : [ '2' , 1 , '3' , 4 , '5' ] } , schema ) ;
515
515
expect ( result . valid ) . toBeFalsy ( ) ;
516
516
expect ( result . errors . length ) . toBe ( 2 ) ;
517
- expect ( result . errors [ 0 ] . property ) . toBe ( 'arr.3 ' ) ;
518
- expect ( result . errors [ 1 ] . property ) . toBe ( 'arr.1 ' ) ;
517
+ expect ( result . errors [ 0 ] . property ) . toBe ( 'arr.1 ' ) ;
518
+ expect ( result . errors [ 1 ] . property ) . toBe ( 'arr.3 ' ) ;
519
519
} ) ;
520
520
521
521
it ( 'should return the array index in the error message when array in array' , function ( ) {
@@ -536,8 +536,8 @@ describe('Validator', function () {
536
536
var result = val . validate ( { arr : [ [ '2' , 1 , '3' ] , [ 4 , '5' ] ] } , schema ) ;
537
537
expect ( result . valid ) . toBeFalsy ( ) ;
538
538
expect ( result . errors . length ) . toBe ( 2 ) ;
539
- expect ( result . errors [ 0 ] . property ) . toBe ( 'arr.1.0 ' ) ;
540
- expect ( result . errors [ 1 ] . property ) . toBe ( 'arr.0.1 ' ) ;
539
+ expect ( result . errors [ 0 ] . property ) . toBe ( 'arr.0.1 ' ) ;
540
+ expect ( result . errors [ 1 ] . property ) . toBe ( 'arr.1.0 ' ) ;
541
541
} ) ;
542
542
543
543
it ( 'should return the array index in the error message when object in array' , function ( ) {
@@ -684,13 +684,13 @@ describe('Validator', function () {
684
684
}
685
685
} , schema ) ;
686
686
expect ( result . valid ) . toBeFalsy ( ) ;
687
- expect ( result . errors [ 1 ] . property ) . toBe ( 'person.addresses.1.street' ) ;
688
- expect ( result . errors [ 0 ] . property ) . toBe ( 'person.addresses.2.users.1' ) ;
687
+ expect ( result . errors [ 0 ] . property ) . toBe ( 'person.addresses.1.street' ) ;
688
+ expect ( result . errors [ 1 ] . property ) . toBe ( 'person.addresses.2.users.1' ) ;
689
689
690
690
result = val . validate ( { arrayWithArrays : [ [ 1 , 2 , 3 ] , [ 4 , '5' , 6 ] , [ '7' , 8 , 9 ] ] } , schema ) ;
691
691
expect ( result . valid ) . toBeFalsy ( ) ;
692
- expect ( result . errors [ 0 ] . property ) . toBe ( 'arrayWithArrays.2.0 ' ) ;
693
- expect ( result . errors [ 1 ] . property ) . toBe ( 'arrayWithArrays.1.1 ' ) ;
692
+ expect ( result . errors [ 0 ] . property ) . toBe ( 'arrayWithArrays.1.1 ' ) ;
693
+ expect ( result . errors [ 1 ] . property ) . toBe ( 'arrayWithArrays.2.0 ' ) ;
694
694
695
695
} ) ;
696
696
@@ -761,8 +761,8 @@ describe('Validator', function () {
761
761
codes : [ 1 , 2 , 3 ]
762
762
} , { name : 'wayne' , codes : [ 1 , 2 , '3' , 4 ] } ] , schema ) ;
763
763
expect ( result . valid ) . toBeFalsy ( ) ;
764
- expect ( result . errors [ 1 ] . property ) . toBe ( '0.codes.1' ) ;
765
- expect ( result . errors [ 0 ] . property ) . toBe ( '2.codes.2' ) ;
764
+ expect ( result . errors [ 0 ] . property ) . toBe ( '0.codes.1' ) ;
765
+ expect ( result . errors [ 1 ] . property ) . toBe ( '2.codes.2' ) ;
766
766
767
767
result = val . validate ( [ {
768
768
name : 'wayne' ,
@@ -778,14 +778,14 @@ describe('Validator', function () {
778
778
}
779
779
] , schema ) ;
780
780
expect ( result . valid ) . toBeFalsy ( ) ;
781
- expect ( result . errors [ 1 ] . property ) . toBe ( '0.addresses.1.street' ) ;
782
- expect ( result . errors [ 0 ] . property ) . toBe ( '0.addresses.2.users.1' ) ;
781
+ expect ( result . errors [ 0 ] . property ) . toBe ( '0.addresses.1.street' ) ;
782
+ expect ( result . errors [ 1 ] . property ) . toBe ( '0.addresses.2.users.1' ) ;
783
783
784
784
result = val . validate ( [ { arrayWithArrays : [ [ 1 , 2 , 3 ] , [ 4 , '5' , 6 ] , [ '7' , 8 , 9 ] ] } , { arrayWithArrays : [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] , [ '7' , 8 , 9 ] ] } ] , schema ) ;
785
785
expect ( result . valid ) . toBeFalsy ( ) ;
786
+ expect ( result . errors [ 0 ] . property ) . toBe ( '0.arrayWithArrays.1.1' ) ;
786
787
expect ( result . errors [ 1 ] . property ) . toBe ( '0.arrayWithArrays.2.0' ) ;
787
- expect ( result . errors [ 2 ] . property ) . toBe ( '0.arrayWithArrays.1.1' ) ;
788
- expect ( result . errors [ 0 ] . property ) . toBe ( '1.arrayWithArrays.2.0' ) ;
788
+ expect ( result . errors [ 2 ] . property ) . toBe ( '1.arrayWithArrays.2.0' ) ;
789
789
790
790
} ) ;
791
791
@@ -802,8 +802,8 @@ describe('Validator', function () {
802
802
var result = val . validate ( [ [ '2' , 1 , '3' ] , [ 4 , '5' ] ] , schema ) ;
803
803
expect ( result . valid ) . toBeFalsy ( ) ;
804
804
expect ( result . errors . length ) . toBe ( 2 ) ;
805
- expect ( result . errors [ 1 ] . property ) . toBe ( '0.1' ) ;
806
- expect ( result . errors [ 0 ] . property ) . toBe ( '1.0' ) ;
805
+ expect ( result . errors [ 0 ] . property ) . toBe ( '0.1' ) ;
806
+ expect ( result . errors [ 1 ] . property ) . toBe ( '1.0' ) ;
807
807
} ) ;
808
808
} ) ;
809
809
@@ -1129,9 +1129,9 @@ describe('Validator', function () {
1129
1129
result = val . validate ( data , schema , { strictRequired : true } ) ;
1130
1130
1131
1131
expect ( result . valid ) . toBeFalsy ( ) ;
1132
- expect ( result . errors [ 0 ] . property ) . toBe ( 'names.3 ' ) ;
1132
+ expect ( result . errors [ 0 ] . property ) . toBe ( 'name ' ) ;
1133
1133
expect ( result . errors [ 0 ] . message ) . toBe ( 'is required' ) ;
1134
- expect ( result . errors [ 1 ] . property ) . toBe ( 'name ' ) ;
1134
+ expect ( result . errors [ 1 ] . property ) . toBe ( 'names.3 ' ) ;
1135
1135
expect ( result . errors [ 1 ] . message ) . toBe ( 'is required' ) ;
1136
1136
} ) ;
1137
1137
0 commit comments