File tree 2 files changed +7
-5
lines changed
2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -949,6 +949,12 @@ export class DateModule {
949
949
refDate ?: string | Date | number ;
950
950
} = { }
951
951
) : Date {
952
+ if ( options . max < options . min ) {
953
+ throw new FakerError (
954
+ `Max ${ options . max } should be larger than or equal to min ${ options . min } .`
955
+ ) ;
956
+ }
957
+
952
958
const mode = options . mode === 'age' ? 'age' : 'year' ;
953
959
const refDate = toDate ( options . refDate , this . faker . defaultRefDate ) ;
954
960
const refYear = refDate . getUTCFullYear ( ) ;
@@ -973,10 +979,6 @@ export class DateModule {
973
979
) ;
974
980
}
975
981
976
- if ( max < min ) {
977
- throw new FakerError ( `Max ${ max } should be larger then min ${ min } .` ) ;
978
- }
979
-
980
982
return new Date ( this . faker . number . int ( { min, max } ) ) ;
981
983
}
982
984
}
Original file line number Diff line number Diff line change @@ -567,7 +567,7 @@ describe('date', () => {
567
567
faker . date . birthdate ( { min, max, mode : 'year' } )
568
568
) . toThrow (
569
569
new FakerError (
570
- `Max 662515200000 should be larger then min 946771200000 .`
570
+ `Max 1990 should be larger than or equal to min 2000 .`
571
571
)
572
572
) ;
573
573
} ) ;
You can’t perform that action at this time.
0 commit comments