allow validations to be cleared.
MODIFY
WalletWasabi.Fluent/Validation/Validations.cs
WalletWasabi.Fluent/Validation/Validations.cs
@@ -36,6 +36,16 @@ namespace WalletWasabi.Fluent.Validation
IEnumerable<string> IValidations.Errors => ErrorsByPropertyName.Values.SelectMany(x => x.Where(x => x.Severity == ErrorSeverity.Error).Select(x => x.Message));
+ public void Clear()
+ {
+ ErrorsByPropertyName.Clear();
+
+ foreach (var propertyName in ValidationMethods.Keys)
+ {
+ ValidateProperty(propertyName, true);
+ }
+ }
+
public void Validate()
{
foreach (var propertyName in ValidationMethods.Keys)
@@ -44,15 +54,19 @@ namespace WalletWasabi.Fluent.Validation
}
}
- public void ValidateProperty(string propertyName)
+
+ public void ValidateProperty(string propertyName, bool clear = false)
{
if (ValidationMethods.TryGetValue(propertyName, out ValidateMethod? validationMethod) && ErrorsByPropertyName.TryGetValue(propertyName, out ErrorDescriptors? currentErrors))
{
// Copy the current errors.
var previousErrors = currentErrors.ToList();
+ if (!clear)
+ {
// Validate.
validationMethod(currentErrors);
+ }
// Clear obsoleted errors and notify properties that changed.
UpdateAndNotify(currentErrors, previousErrors, propertyName);

MODIFY
WalletWasabi.Fluent/ViewModels/ViewModelBase.cs
WalletWasabi.Fluent/ViewModels/ViewModelBase.cs
@@ -19,6 +19,11 @@ namespace WalletWasabi.Fluent.ViewModels
public event EventHandler<DataErrorsChangedEventArgs>? ErrorsChanged;
+ protected void ClearValidations()
+ {
+ _validations.Clear();
+ }
+
protected IValidations Validations => _validations;
bool INotifyDataErrorInfo.HasErrors => Validations.Any;

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendViewModel.cs
@@ -246,9 +246,10 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
{
if (!inHistory)
{
- _to = "";
- _amountBtc = 0;
+ To = "";
+ AmountBtc = 0;
Labels.Clear();
+ ClearValidations();
}
_owner.Wallet.Synchronizer.WhenAnyValue(x => x.UsdExchangeRate)

allow validations to be cleared.