@@ -471,7 +471,7 @@ describe("IsLatLong", function () {
471
471
472
472
it ( "should fail if validator.validate said that its invalid" , function ( done ) {
473
473
checkInvalidValues ( new MyClass ( ) , invalidValues , done ) ;
474
- } ) ;
474
+ } ) ;
475
475
476
476
} ) ;
477
477
describe ( "IsLatitude" , function ( ) {
@@ -573,6 +573,11 @@ describe("IsNumber", function() {
573
573
someProperty : number ;
574
574
}
575
575
576
+ class ZeroDecimalPlacesTest {
577
+ @IsNumber ( { maxDecimalPlaces : 0 } )
578
+ someProperty : number ;
579
+ }
580
+
576
581
it ( "should fail if NaN passed without allowing NaN values" , function ( done ) {
577
582
checkInvalidValues ( new MyClass ( ) , [ NaN ] , done ) ;
578
583
} ) ;
@@ -619,6 +624,14 @@ describe("IsNumber", function() {
619
624
checkInvalidValues ( new MaxDecimalPlacesTest ( ) , [ 1.1234 ] , done ) ;
620
625
} ) ;
621
626
627
+ it ( "should pass if number of decimal places is zero" , function ( done ) {
628
+ checkValidValues ( new ZeroDecimalPlacesTest ( ) , [ - 10 , - 1 , 0 , 1 , 10 ] , done ) ;
629
+ } ) ;
630
+
631
+ it ( "should fail if number of decimal places is not zero" , function ( done ) {
632
+ checkInvalidValues ( new ZeroDecimalPlacesTest ( ) , [ - 11.1 , - 2.2 , - 0.1 , 0.1 , 2.2 , 11.1 ] , done ) ;
633
+ } ) ;
634
+
622
635
} ) ;
623
636
624
637
describe ( "IsInt" , function ( ) {
@@ -3281,19 +3294,19 @@ describe("isHash", function() {
3281
3294
it ( "should not fail if validator.validate said that its valid" , function ( done ) {
3282
3295
checkValidValues ( new MyClass ( ) , validValues , done ) ;
3283
3296
} ) ;
3284
-
3297
+
3285
3298
it ( "should fail if validator.validate said that its invalid" , function ( done ) {
3286
3299
checkInvalidValues ( new MyClass ( ) , invalidValues , done ) ;
3287
3300
} ) ;
3288
-
3301
+
3289
3302
it ( "should not fail if method in validator said that its valid" , function ( ) {
3290
3303
validValues . forEach ( value => validator . isHash ( value , algorithm ) . should . be . true ) ;
3291
3304
} ) ;
3292
-
3305
+
3293
3306
it ( "should fail if method in validator said that its invalid" , function ( ) {
3294
3307
invalidValues . forEach ( value => validator . isHash ( value , algorithm ) . should . be . false ) ;
3295
3308
} ) ;
3296
-
3309
+
3297
3310
it ( "should return error object with proper data" , function ( done ) {
3298
3311
const validationType = "isHash" ;
3299
3312
const message = `someProperty must be a hash of type ${ algorithm } ` ;
@@ -3354,7 +3367,7 @@ describe("isHash", function() {
3354
3367
"39485729348" ,
3355
3368
"%&FHKJFvk" ,
3356
3369
] ;
3357
-
3370
+
3358
3371
testHash ( algorithm , validValues , invalidValues ) ;
3359
3372
} ) ;
3360
3373
@@ -3373,7 +3386,7 @@ describe("isHash", function() {
3373
3386
"39485729348" ,
3374
3387
"%&FHKJFvk" ,
3375
3388
] ;
3376
-
3389
+
3377
3390
testHash ( algorithm , validValues , invalidValues ) ;
3378
3391
} ) ;
3379
3392
@@ -3392,7 +3405,7 @@ describe("isHash", function() {
3392
3405
"39485729348" ,
3393
3406
"%&FHKJFvk" ,
3394
3407
] ;
3395
-
3408
+
3396
3409
testHash ( algorithm , validValues , invalidValues ) ;
3397
3410
} ) ;
3398
3411
@@ -3411,7 +3424,7 @@ describe("isHash", function() {
3411
3424
"39485729348" ,
3412
3425
"%&FHKJFvk" ,
3413
3426
] ;
3414
-
3427
+
3415
3428
testHash ( algorithm , validValues , invalidValues ) ;
3416
3429
} ) ;
3417
3430
@@ -3430,9 +3443,9 @@ describe("isHash", function() {
3430
3443
"39485729348" ,
3431
3444
"%&FHKJFvk" ,
3432
3445
] ;
3433
-
3446
+
3434
3447
testHash ( algorithm , validValues , invalidValues ) ;
3435
- } ) ;
3448
+ } ) ;
3436
3449
} ) ;
3437
3450
3438
3451
describe ( "IsISSN" , function ( ) {
0 commit comments