Skip to content
Merged
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
11 changes: 8 additions & 3 deletions AppifySheets.Immutable.BankIntegrationTypes/BankAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ public record BankAccount
/// <summary>
/// Creates a bank account with validation
/// </summary>
public static Result<BankAccount> Create(string iban, string currencyCode)
/// <param name="iban">The IBAN or account number</param>
/// <param name="currencyCode">The currency code</param>
/// <param name="validateIban">Whether to validate the IBAN format (default: true)</param>
public static Result<BankAccount> 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<BankAccount>($"Invalid IBAN: {ibanResult.Error}");
return Result.Failure<BankAccount>($"Invalid {(validateIban ? "IBAN" : "account number")}: {ibanResult.Error}");

var currencyResult = Currency.Create(currencyCode);
if (currencyResult.IsFailure)
Expand Down
13 changes: 13 additions & 0 deletions AppifySheets.Immutable.BankIntegrationTypes/Iban.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ public static Result<Iban> Create(string value)
return Result.Success(new Iban(normalized));
}

/// <summary>
/// Creates an IBAN instance without validation (for non-IBAN account numbers)
/// </summary>
internal static Result<Iban> CreateWithoutValidation(string value)
{
if (string.IsNullOrWhiteSpace(value))
return Result.Failure<Iban>("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;

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0
2.1.0
Loading