StringMate 0.0.11

dotnet add package StringMate --version 0.0.11
NuGet\Install-Package StringMate -Version 0.0.11
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="StringMate" Version="0.0.11" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add StringMate --version 0.0.11
#r "nuget: StringMate, 0.0.11"
#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 StringMate as a Cake Addin
#addin nuget:?package=StringMate&version=0.0.11

// Install StringMate as a Cake Tool
#tool nuget:?package=StringMate&version=0.0.11

StringMate offers a collection of useful classes designed for working with the C# string type.

  • StringValidation is a static class which contains all the validation methods.
  • Since it is a Static class, garbage collection won't be an issue.
  • To install, run dotnet add package StringMate or from Nuget

Example Usage:

using StringMate.Validators;
using StringMate.Helpers;


var resultOfTimeValidation = StringValidation.Is12HourTime("06:10 PM", includeSecond: false);
if (resultOfTimeValidation) Console.WriteLine("Yee! Validated time");


var constructedDateFormat = new DateFormatBuilder()
    .AddDayWithLeadingZero()
    .AddMonthWithLeadingZero()
    .AddYearWithFourDigit()
    .AddHyphenDelimiter()
    .Build();

var resultOfDateValidation = StringValidation.IsDate("10-11-2014", dateFormat: constructedDateFormat);
if (resultOfDateValidation) Console.WriteLine("Yee! Validated date");

Available Methods in StringValidation Class

Method Signature Description
IsDate bool IsDate(string text, string dateFormat) Validates date. Supports - or / as delimiter. Use the DateFormatBuilder helper class to construct the dateFormat parameter. IDateFormatBuilder interface is also included for loose coupling and dependency injection purpose.
Is12HourTime bool Is12HourTime(string text, bool includeSecond) Validates 12-hour time format.
Is24HourTime bool Is24HourTime(string text, bool includeSecond) Validates 24-hour time format.
IsStrongPassword IsStrongPassword(string text, int minLength = 8, int minLowercase = 1, int minUppercase = 1, int minNumbers = 1, int minSymbols = 1, int minUniqueChars = 0) Validates whether the input string represents a strong password. Default parameters are added for convenience.
IsHash bool IsHash(string text, HashingAlgorithm algorithm) Validates hash based on the specified hashing algorithm.HashingAlgorithm is an enum type.
IsSlug bool IsSlug(string text) Validates slug.
IsMongoId bool IsMongoId(string text) Validates MongoDB ObjectId.
IsUuid bool IsUuid(string text, UuidVersion version) Validates UUID based on the specified version. UuidVersion is an enum type.
IsJwt bool IsJwt(string text) Validates JSON Web Token (JWT).
IsBase64 bool IsBase64(string text, bool checkUrlSafety) Validates Base64-encoded string, with URL safety check.
IsEnumMember bool IsEnumMember<TEnum>(string text) Validates enum member of the given enum generic type parameter.
IsHexadecimal bool IsHexadecimal(string text) Validates hexadecimal number.

Available Data Annotations based on StringValidation class

Attribute Data Annotation Description
HexadecimalAttribute [Hexadecimal] Validates property value of hexadecimal number.
JsonWebTokenAttribute [JsonWebToken] Validates property value of JSON Web Token (JWT).
MongoIdAttribute [MongoId] Validates property value of MongoDB ObjectId.
SlugAttribute [Slug] Validates property value of slug.
HashAttribute [Hash(HashingAlgorithm algorithm)] Validates property value of hash based on the specified hashing algorithm.
StrongPasswordAttribute [StrongPassword] or [StrongPassword(int minLength = 8, int minLowercase = 1, int minUppercase = 1, int minNumbers = 1, int minSymbols = 1, int minUniqueChars = 0) Validates property value of strong password. Default parameters are added for convenience.
DateAttribute [Date] or [Date(string dateFormat)] Validates property value of date. Supports - or / as delimiter. Use the DateFormatBuilder helper class to construct the dateFormat parameter. IDateFormatBuilder interface is also included for loose coupling and dependency injection purpose.
TimeOf12HourAttribute [TimeOf12Hour(bool includeSecond)] Validates property value of 12-hour time format.
TimeOf24HourAttribute [TimeOf24Hour(bool includeSecond)] Validates property value of 24-hour time format.
UuidAttribute [Uuid(UuidVersion version)] or [Uuid] Validates property value of UUID. Optionally specifies the UUID version for validation.
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  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 is compatible.  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 is compatible.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
0.0.11 101 4/4/2024