aboutsummaryrefslogtreecommitdiff
path: root/src/modules/commerce
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2023-11-14 17:11:26 +0100
committerGitHub <[email protected]>2023-11-14 16:11:26 +0000
commit7e3c92e802614ae5e9f621d9e679dfd6f6d63cf1 (patch)
treebb6813a857c0c42ba1049be5035fce7f45b99c46 /src/modules/commerce
parent36fc517d17591c8ea1d5135d9a93c7591e3d1f74 (diff)
downloadfaker-7e3c92e802614ae5e9f621d9e679dfd6f6d63cf1.tar.xz
faker-7e3c92e802614ae5e9f621d9e679dfd6f6d63cf1.zip
infra: enable strictNullChecks in tsconfig (#2435)
Diffstat (limited to 'src/modules/commerce')
-rw-r--r--src/modules/commerce/index.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/modules/commerce/index.ts b/src/modules/commerce/index.ts
index 1be3fcb2..425bc848 100644
--- a/src/modules/commerce/index.ts
+++ b/src/modules/commerce/index.ts
@@ -1,3 +1,4 @@
+import { FakerError } from '../../errors/faker-error';
import { deprecated } from '../../internal/deprecated';
import { ModuleBase } from '../../internal/module-base';
@@ -401,7 +402,14 @@ export class CommerceModule extends ModuleBase {
const registrantLength = groupRules.find(
([rangeMaximum]) => elementValue <= rangeMaximum
- )[1];
+ )?.[1];
+
+ if (!registrantLength) {
+ // This can only happen if the ISBN_LENGTH_RULES are corrupted
+ throw new FakerError(
+ `Unable to find a registrant length for the group ${group}`
+ );
+ }
const registrant = element.slice(0, registrantLength);
const publication = element.slice(registrantLength);