add IsTrimable to string extension
MODIFY
WalletWasabi.Fluent/ViewModels/AddWalletPageViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWalletPageViewModel.cs
@@ -72,7 +72,7 @@ namespace WalletWasabi.Fluent.ViewModels
return;
}
- if (PasswordHelper.IsTrimable(walletName, out _))
+ if (walletName.IsTrimable())
{
errors.Add(ErrorSeverity.Error, "Leading and trailing white spaces are not allowed!");
return;

MODIFY
WalletWasabi/Extensions/StringExtensions.cs
WalletWasabi/Extensions/StringExtensions.cs
@@ -60,5 +60,20 @@ namespace System
}
return me;
}
+
+ public static bool IsTrimable(this string? me)
+ {
+ if (me is null)
+ {
+ return false;
+ }
+
+ if (me.Length != me.Trim().Length)
+ {
+ return true;
+ }
+
+ return false;
+ }
}
}

MODIFY
WalletWasabi/Userfacing/PasswordHelper.cs
WalletWasabi/Userfacing/PasswordHelper.cs
@@ -71,17 +71,15 @@ namespace WalletWasabi.Userfacing
public static bool IsTrimable(string? password, out string? trimmedPassword)
{
trimmedPassword = password;
+
if (password is null)
{
return false;
}
- var beforeTrim = password.Length;
-
- trimmedPassword = password.Trim();
-
- if (beforeTrim != trimmedPassword.Length)
+ if (password.IsTrimable())
{
+ trimmedPassword = password.Trim();
return true;
}

add IsTrimable to string extension