DimonSmart.StringTrimmer 1.2.1

Prefix Reserved
dotnet add package DimonSmart.StringTrimmer --version 1.2.1                
NuGet\Install-Package DimonSmart.StringTrimmer -Version 1.2.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DimonSmart.StringTrimmer" Version="1.2.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DimonSmart.StringTrimmer --version 1.2.1                
#r "nuget: DimonSmart.StringTrimmer, 1.2.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DimonSmart.StringTrimmer as a Cake Addin
#addin nuget:?package=DimonSmart.StringTrimmer&version=1.2.1

// Install DimonSmart.StringTrimmer as a Cake Tool
#tool nuget:?package=DimonSmart.StringTrimmer&version=1.2.1                

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.1 306 12/20/2022
1.2.0 280 12/19/2022
1.1.0 306 12/1/2022
1.0.0 312 11/29/2022