diff options
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/finance/index.ts | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/modules/finance/index.ts b/src/modules/finance/index.ts index c73bf6ae..b70950be 100644 --- a/src/modules/finance/index.ts +++ b/src/modules/finance/index.ts @@ -429,19 +429,30 @@ export class FinanceModule { /** * Generates a random SWIFT/BIC code based on the [ISO-9362](https://en.wikipedia.org/wiki/ISO_9362) format. * + * @param options Options object. + * @param options.includeBranchCode Whether to include a three-digit branch code at the end of the generated code. Defaults to a random boolean value. + * * @example - * faker.finance.bic() // 'WYAUPGX1432' + * faker.finance.bic() // 'WYAUPGX1' + * faker.finance.bic({ includeBranchCode: true }) // 'KCAUPGR1432' + * faker.finance.bic({ includeBranchCode: false }) // 'XDAFQGT7' * * @since 4.0.0 */ - bic(): string { + bic( + options: { + includeBranchCode?: boolean; + } = {} + ): string { + const { includeBranchCode = this.faker.datatype.boolean() } = options; + const bankIdentifier = this.faker.random.alpha({ count: 4, casing: 'upper', }); const countryCode = this.faker.helpers.arrayElement(iban.iso3166); const locationCode = this.faker.random.alphaNumeric(2, { casing: 'upper' }); - const branchCode = this.faker.datatype.boolean() + const branchCode = includeBranchCode ? this.faker.datatype.boolean() ? this.faker.random.alphaNumeric(3, { casing: 'upper' }) : 'XXX' |
