Skip to content

Commit

Permalink
[ViesManager] IsValid throws error message for GB VATs (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Popescu committed Dec 18, 2023
1 parent 991f8dc commit e553436
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/vies-dotnet-api/ViesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ private static IVatValidator GetValidator(string countryCode)
private readonly HttpClient _httpClient;
private readonly ViesService _viesService;

private static readonly Dictionary<string, ExcludedCountryInfo> _excludedCountries = new(StringComparer.OrdinalIgnoreCase)
{
{"GB", new ExcludedCountryInfo("GB", "Great Britain", "Brexit", "2021-01-01")},
};

/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -103,6 +108,10 @@ public static VatValidationResult IsValid(string vat)
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public static VatValidationResult IsValid(string countryCode, string vatNumber)
{
if (_excludedCountries.TryGetValue(countryCode, out var excludedCountryInfo))
{
return VatValidationResult.Failed(excludedCountryInfo.ToString());
}
var validator = GetValidator(countryCode);
return validator == null
? VatValidationResult.Failed($"{countryCode} is not a valid ISO_3166-1 European member state.")
Expand Down

0 comments on commit e553436

Please sign in to comment.