DimonSmart.StringTrimmer
1.2.0
Prefix Reserved
See the version list below for details.
dotnet add package DimonSmart.StringTrimmer --version 1.2.0
NuGet\Install-Package DimonSmart.StringTrimmer -Version 1.2.0
<PackageReference Include="DimonSmart.StringTrimmer" Version="1.2.0" />
paket add DimonSmart.StringTrimmer --version 1.2.0
#r "nuget: DimonSmart.StringTrimmer, 1.2.0"
// Install DimonSmart.StringTrimmer as a Cake Addin #addin nuget:?package=DimonSmart.StringTrimmer&version=1.2.0 // Install DimonSmart.StringTrimmer as a Cake Tool #tool nuget:?package=DimonSmart.StringTrimmer&version=1.2.0
StringTrimmer
Don't ever rely on user input! This package offers the ability to trim every string in a class. Sanitizing input data before processing is beneficial.
Problem statement
Standard class for describing a user.
public class User
{
public string Name {get; set;}
public string Surname {get; set;}
public string Secondname {get; set;}
public string UserName {get; set;}
public string Email {get; set;}
public string Phone {get; set;}
}
Usage of the User class to add a new User record to the database is typical.
Can you find an error?
Try
public void CreateUser (User user)
{
user.Name = user.Name.Trim();
user.Surname = user.Surname.Trim();
user.Secondname = user.Secondname.Trim();
user.Email = user.Email.Trim();
user.Phone = user.Phone.Trim();
}
Error: UserName Trim command is missing. Due to the tiny difference in UserName, this allows for many users while having only one real user.
- "John Doe "
- " John Doe"
- " John Doe "
- "John Doe"
Having the same user registered many times irritates the support personnel!
Note: It is usual for users to not merely input a UserName during registration, but to copy it from other sources with different spaces surrounding (and inside) the name.
Magic bullet! (Usage example)
Try
public void CreateUser (User user)
{
user.TrimExtraSpaces(); // Just one line
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- System.Runtime.Caching (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.