Skip to content

Commit

Permalink
Fixed bank account length (#1477)
Browse files Browse the repository at this point in the history
- Also fixed it so that extra long bank account numbers are valid
  • Loading branch information
jguthrie100 authored and vbrazo committed Dec 8, 2018
1 parent cbce628 commit 40a02a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/faker/default/bank.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ class Bank < Base
flexible :bank

class << self
def account_number(digits = 11)
rand.to_s[2..digits]
def account_number(digits = 10)
output = ''

output += rand.to_s[2..-1] while output.length < digits

output[0...digits]
end

def iban(country_code = 'GB')
Expand Down
4 changes: 4 additions & 0 deletions test/faker/default/test_faker_bank.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def test_routing_number_with_format

def test_account_number
assert Faker::Bank.account_number.match(/\d{10}/)

assert Faker::Bank.account_number(12).match(/\d{12}/)

assert Faker::Bank.account_number(100).match(/\d{100}/)
end

def test_name
Expand Down

0 comments on commit 40a02a7

Please sign in to comment.