Skip to content

Commit

Permalink
Credit card fix for Visa, Mastercard, Discover and Diners Club. Fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
bodiam committed Oct 20, 2022
1 parent e37d73e commit 17a6b38
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/main/resources/en/finance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,32 @@ en:
finance:
credit_card:
visa:
- /4###########L/
- /4###-####-####-###L/
mastercard:
- /6771-89##-####-###L/
- /50##-####-####-###L/
- /51##-####-####-###L/
- /52##-####-####-###L/
- /53##-####-####-###L/
- /54##-####-####-###L/
- /55##-####-####-###L/
discover:
- /6011-####-####-###L/
- /65##-####-####-###L/
- /6011-62##-####-####-###L/
- /65##-62##-####-####-###L/
- /6011-00##-####-###L/
- /6011-10##-####-###L/
- /6011-20##-####-###L/
- /6516-21##-####-###L/
- /6550-66##-####-###L/
- /6595-24##-####-###L/
american_express:
- /34##-######-####L/
- /37##-######-####L/
diners_club:
- /368#-######-###L/
- /30##-######-###L/
- /36##-######-###L/
- /38##-######-###L/
jcb:
- /3528-####-####-###L/
- /3529-####-####-###L/
- /2123-####-####-###L/
- /1800-####-####-###L/
- /3###-######-####L/
switch:
- /6759-####-####-###L/
- /6759-####-####-####-#L/
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/net/datafaker/providers/base/FinanceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,16 @@ void costaRicaIbanMustBeValid() {
final String ibanFaker = faker.finance().iban(givenCountryCode).toUpperCase(faker.getContext().getLocale());
assertThat(fr.marcwrobel.jbanking.iban.Iban.isValid(ibanFaker)).isTrue();
}

@RepeatedTest(100)
void visaCard() {
String creditCard = faker.finance().creditCard(CreditCardType.VISA).replace("-", "");
assertThat(creditCard).startsWith("4").hasSize(16);
}

@RepeatedTest(100)
void discoverCard() {
String creditCard = faker.finance().creditCard(CreditCardType.DISCOVER).replace("-", "");
assertThat(creditCard).startsWith("6").hasSize(16);
}
}

0 comments on commit 17a6b38

Please sign in to comment.