Skip to content

Commit

Permalink
Fix issue #538 - invalid Costa Rican IBAN format (#546)
Browse files Browse the repository at this point in the history
* Add test for Costa Rican IBAN

* Update CR IBAN format in extended locale data

* run gulp importLocales, excluding AR locale

* Update EN locale schema snapshot
  • Loading branch information
dangerman committed Apr 28, 2024
1 parent 0eb7ea5 commit 8065725
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 6 deletions.
25 changes: 25 additions & 0 deletions Source/Bogus.Tests/GitHubIssues/Issue538.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Bogus.DataSets;
using FluentAssertions;
using Xunit;

namespace Bogus.Tests.GitHubIssues;

public class Issue538 : SeededTest
{
[Fact]
public void can_generate_valid_costa_rican_iban()
{
// Costa Rican IBANs should match the following format:
// https://bank-code.net/iban/structure/costa-rica-international-bank-account-number
// e.g. CR05 0152 0200 1026 2840 66
var finance = new Finance();
var iban = finance.Iban(countryCode: "CR");

var countryCode = iban.Substring(0, 2);
var digitsAfterCountryCode = iban.Substring(2, 20);

iban.Should().HaveLength(22);
countryCode.Should().Be("CR");
digitsAfterCountryCode.Should().MatchRegex("^[0-9]{20}$");
}
}
Binary file modified Source/Bogus/data/en.locale.bson
Binary file not shown.
8 changes: 6 additions & 2 deletions Source/Bogus/data/en.locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -9227,8 +9227,12 @@
},
{
"country": "CR",
"total": 21,
"total": 22,
"bban": [
{
"type": "n",
"count": 1
},
{
"type": "n",
"count": 3
Expand All @@ -9238,7 +9242,7 @@
"count": 14
}
],
"format": "CRkk bbbc cccc cccc cccc c"
"format": "CRkk xbbb cccc cccc cccc cc"
},
{
"country": "HR",
Expand Down
8 changes: 6 additions & 2 deletions Source/Bogus/data/en.locale.schema.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,10 @@
},
{
bban: [
{
count: 1,
type: n
},
{
count: 3,
type: n
Expand All @@ -1100,8 +1104,8 @@
}
],
country: CR,
format: CRkk bbbc cccc cccc cccc c,
total: 21
format: CRkk xbbb cccc cccc cccc cc,
total: 22
},
{
bban: [
Expand Down
8 changes: 6 additions & 2 deletions Source/Bogus/data_extend/en.locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,12 @@
},
{
"country": "CR",
"total": 21,
"total": 22,
"bban": [
{
"type": "n",
"count": 1
},
{
"type": "n",
"count": 3
Expand All @@ -481,7 +485,7 @@
"count": 14
}
],
"format": "CRkk bbbc cccc cccc cccc c"
"format": "CRkk xbbb cccc cccc cccc cc"
},
{
"country": "HR",
Expand Down

0 comments on commit 8065725

Please sign in to comment.