diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/finance.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/finance.js b/lib/finance.js index 2939a659..8eaf0de9 100644 --- a/lib/finance.js +++ b/lib/finance.js @@ -255,8 +255,14 @@ self.litecoinAddress = function () { * @method faker.finance.iban */ self.iban = function (formatted, countryCode) { - var findFormat = function(currentFormat) { return currentFormat.country === countryCode; }; - var ibanFormat = countryCode ? ibanLib.formats.find(findFormat) : faker.random.arrayElement(ibanLib.formats); + var ibanFormat; + if (countryCode) { + var findFormat = function(currentFormat) { return currentFormat.country === countryCode; }; + ibanFormat = ibanLib.formats.find(findFormat); + } else { + ibanFormat = faker.random.arrayElement(ibanLib.formats); + } + if (!ibanFormat) { throw new Error('Country code ' + countryCode + ' not supported.'); } |
