diff --git a/AppifySheets.Immutable.BankIntegrationTypes/BankAccount.cs b/AppifySheets.Immutable.BankIntegrationTypes/BankAccount.cs index 7a4c199..9dc7317 100644 --- a/AppifySheets.Immutable.BankIntegrationTypes/BankAccount.cs +++ b/AppifySheets.Immutable.BankIntegrationTypes/BankAccount.cs @@ -19,11 +19,16 @@ public record BankAccount /// /// Creates a bank account with validation /// - public static Result Create(string iban, string currencyCode) + /// The IBAN or account number + /// The currency code + /// Whether to validate the IBAN format (default: true) + public static Result Create(string iban, string currencyCode, bool validateIban = true) { - var ibanResult = Iban.Create(iban); + // Create IBAN with or without validation based on the flag + var ibanResult = validateIban ? Iban.Create(iban) : Iban.CreateWithoutValidation(iban); + if (ibanResult.IsFailure) - return Result.Failure($"Invalid IBAN: {ibanResult.Error}"); + return Result.Failure($"Invalid {(validateIban ? "IBAN" : "account number")}: {ibanResult.Error}"); var currencyResult = Currency.Create(currencyCode); if (currencyResult.IsFailure) diff --git a/AppifySheets.Immutable.BankIntegrationTypes/Iban.cs b/AppifySheets.Immutable.BankIntegrationTypes/Iban.cs index 9b18eb0..c50e177 100644 --- a/AppifySheets.Immutable.BankIntegrationTypes/Iban.cs +++ b/AppifySheets.Immutable.BankIntegrationTypes/Iban.cs @@ -40,6 +40,19 @@ public static Result Create(string value) return Result.Success(new Iban(normalized)); } + /// + /// Creates an IBAN instance without validation (for non-IBAN account numbers) + /// + internal static Result CreateWithoutValidation(string value) + { + if (string.IsNullOrWhiteSpace(value)) + return Result.Failure("Account number cannot be empty"); + + // Just normalize by removing spaces and converting to uppercase + var normalized = value.Replace(" ", "").ToUpperInvariant(); + return Result.Success(new Iban(normalized)); + } + public override string ToString() => Value; diff --git a/VERSION b/VERSION index 359a5b9..50aea0e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.0 \ No newline at end of file +2.1.0 \ No newline at end of file