aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/date/index.ts10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/modules/date/index.ts b/src/modules/date/index.ts
index d7a0f12a..7156bf22 100644
--- a/src/modules/date/index.ts
+++ b/src/modules/date/index.ts
@@ -949,6 +949,12 @@ export class DateModule {
refDate?: string | Date | number;
} = {}
): Date {
+ if (options.max < options.min) {
+ throw new FakerError(
+ `Max ${options.max} should be larger than or equal to min ${options.min}.`
+ );
+ }
+
const mode = options.mode === 'age' ? 'age' : 'year';
const refDate = toDate(options.refDate, this.faker.defaultRefDate);
const refYear = refDate.getUTCFullYear();
@@ -973,10 +979,6 @@ export class DateModule {
);
}
- if (max < min) {
- throw new FakerError(`Max ${max} should be larger then min ${min}.`);
- }
-
return new Date(this.faker.number.int({ min, max }));
}
}