diff options
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); |
