faker
faker copied to clipboard
Branch code option for SWIFT/BIC codes
From bank.codes: "SWIFT codes are laid out in a standard format. You'll find 8 letters or digits for a standard SWIFT code, or 11 if you also have the branch code added. The last 3 digits which show the specific branch an account is held at are not always necessary."
Currently, finance.bic() uses a ternary operator https://github.com/faker-js/faker/blob/df9c650432de2d119b4f17d61a0c554b744debd0/src/modules/finance/index.ts#L412-L414 to randomly decide whether to generate an 8 char or 11 char SWIFT code.
I propose that we add a boolean branchCode parameter to finance.bic() to give users the ability to pick whether they want a standard SWIFT code or a code with the branch code at the end.
It should still be possible to call the function and get 8 or 11 as result so your test suit can handle both kind of data So we might need a string union literal. Also consider using an option object, even if there is currently only one option, but it's more easy extendable.
FFR: https://github.com/faker-js/faker/blob/df9c650432de2d119b4f17d61a0c554b744debd0/src/modules/finance/index.ts#L412-L414
It should still be possible to call the function and get 8 or 11 as result so your test suit can handle both kind of data So we might need a string union literal. Also consider using an option object, even if there is currently only one option, but it's more easy extendable.
Yeah, most of the functions with parameters use options objects, so we should keep it consistent and have one here as well.
I fixed the bug in #1171, and if you accept it I can extend it with these additional parameters to control branch code generation...
I fixed the bug in #1171, and if you accept it I can extend it with these additional parameters to control branch code generation...
Hmm, I would say submit #1171 first, then make a new PR with the options object and new parameter added to the function. Thank you for your PR!
I fixed the bug in #1171, and if you accept it I can extend it with these additional parameters to control branch code generation...
Hi Hanna, are you on this issue? I could take it, if you wish. Thank you for your help with the implementation fix!