aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEric Cheng <[email protected]>2022-09-22 12:27:19 -0400
committerGitHub <[email protected]>2022-09-22 18:27:19 +0200
commitfe97c29ef888b41582d4ad55753c7eb7e4bac6fc (patch)
tree224c22d1caf7b59008e0d0137a9d75cd7b85764c /src
parentea8d873c5388f405fbdd18ad4ff978bc49996868 (diff)
downloadfaker-fe97c29ef888b41582d4ad55753c7eb7e4bac6fc.tar.xz
faker-fe97c29ef888b41582d4ad55753c7eb7e4bac6fc.zip
feat(finance): branch code option in bic() (#1378)
Diffstat (limited to 'src')
-rw-r--r--src/modules/finance/index.ts17
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'