Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/validators/country.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,15 @@
"PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG",
"QAR",
"RON", "RSD", "RUB", "RWF",
"SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLL", "SOS",
"SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLE", "SLL", "SOS",
"SRD", "SSP", "STN", "SVC", "SYP", "SZL",
"THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TWD", "TZS",
"UAH", "UGX", "USD", "UYU", "UZS",
"VED", "VES", "VND", "VUV",
"WST",
"XAF", "XCD", "XDR", "XOF", "XPF",
"XAF", "XCD", "XCG", "XDR", "XOF", "XPF",
"YER",
"ZAR", "ZMW", "ZWL"
"ZAR", "ZMW", "ZWG", "ZWL"
}
_currency_symbols = {
# https://en.wikipedia.org/wiki/Currency_sign_(generic)
Expand Down
20 changes: 20 additions & 0 deletions tests/test_country.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,23 @@ def test_returns_failed_validation_invalid_currency(
assert isinstance(
currency(value, skip_symbols=skip_symbols, ignore_case=ignore_case), ValidationError
)


@pytest.mark.parametrize("value", ["SLE", "XCG", "ZWG"])
@pytest.mark.parametrize("skip_symbols", [True, False])
def test_accepts_current_currency_codes(value: str, skip_symbols: bool):
"""Accept the current Leone, Caribbean guilder and Zimbabwe Gold codes."""
assert currency(value, skip_symbols=skip_symbols) is True


@pytest.mark.parametrize("value", ["sle", "xcg", "zwg"])
def test_current_currency_codes_respect_ignore_case(value: str):
"""Only accept lowercase currency codes when case-insensitive matching is enabled."""
assert isinstance(currency(value), ValidationError)
assert currency(value, ignore_case=True) is True


@pytest.mark.parametrize("value", ["SLL", "ANG", "ZWL"])
def test_preserves_legacy_currency_codes(value: str):
"""Keep previously accepted codes when adding their current replacements."""
assert currency(value) is True