diff options
| author | ST-DDT <[email protected]> | 2023-11-14 17:11:26 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-14 16:11:26 +0000 |
| commit | 7e3c92e802614ae5e9f621d9e679dfd6f6d63cf1 (patch) | |
| tree | bb6813a857c0c42ba1049be5035fce7f45b99c46 /src/modules/commerce | |
| parent | 36fc517d17591c8ea1d5135d9a93c7591e3d1f74 (diff) | |
| download | faker-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.ts | 10 |
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); |
