SomeValidation 1.2.0

dotnet add package SomeValidation --version 1.2.0
                    
NuGet\Install-Package SomeValidation -Version 1.2.0
                    
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="SomeValidation" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SomeValidation" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="SomeValidation" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SomeValidation --version 1.2.0
                    
#r "nuget: SomeValidation, 1.2.0"
                    
#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.
#:package SomeValidation@1.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SomeValidation&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=SomeValidation&version=1.2.0
                    
Install as a Cake Tool

SomeValidation library for .NET C#

Contributions and functionality additions to the project are welcome

place star if this lib was helpful! https://github.com/richismyhoo/SomeValidation

this library contains some methods what resolves popular problems of validation, easy names for methods, easy to start

Some examples with data types

IsValidEmail(string)

IsValidPhone(string)

IsValidPassword(string, int minLength)also checking for some bad symbols

IsValidGuid(string)

IsValidIPv6(string) & IsValidIPv4(string)

IsFileSizeValid(string filePath, string sizeWithUnit) accepting second string "b" bytes, "kb" - kilobytes, "mb" - megabytes, "gb" - gigabytes

IsSafeXSS(string)

IsValidVIN(string)

IsValidCardNumber(string)

IsValidMD5(string)

and lot more

Some examples to usage

string uuid = "550e8400-e29b-41d4-a716-446655440000"; 
Console.WriteLine(UUIDValidator.IsValidUUID(uuid));
string cardNumber = "4539 1488 0343 6467";
Console.WriteLine(CardValidator.IsValidCardNumber(cardNumber));

Documentation for library methods

You can see available in latest version country codes and currency codes in /src/StaticValues.cs

IsValidEmail(string email) //checking email string for validity

IsValidIsoDate(string date)  //checking is iso date string correct

InRange(int value, int min, int max) //checking is number > min and < max

IsMinLength(int minLength, string stringToCheck) //checking is string length more than minimal requirement

IsLengthInRange(int min, int max, string toCheck) //check is string length > minLength and < maxLength

IsValidPhone(string phone) //check is phone number correct

IsValidUrl(string url) //check is string url 

IsValidPassword(string password, int minLength) //check is password more than minimal length, and doesnt contain bad symbols

IsValidName(string name, List<char> invalidChars) //check is name contains some bad symbols (you are choosing what symbols is bad in this case)

IsValidGuid(string guid) //well, check is Guid string is valid

IsValidIPv4(string ip) //check is it ipv4

IsValidIPv6(string ip) // check is it ipv6

IsValidFileExtension(string filePath, string[] extensions) //check is this file in some right extension

IsFileSizeValid(string filePath, string sizeWithUnit) // types of sizes - "b', "kb", "mb", "gb"

IsValidBase64(string base64String) //check is string valid base64 string

IsValidEnumValue(string value) // is string value correct part of enum

IsSafeSQL(string input) // check is string contains some sql injection symbols/words

IsSafeXSS(string input) // check is this string safe and doesnt contains xss attack 

IsValidJwt(string token) // check is this jwt token valid

IsValidLatitude(double) isValidLongitude(double) IsValidCoordinates(double latitude, double longitude) // check coordinates

IsInCircularZone(double latitude, double longitude, double centerLatitude, double centerLongitude, double radiusKm) // check is coords in circular zone

DegreeToRadian(double degree) // degree to radian

IsValidCountryCode(string countryCode) // check is this country code valid

IsValidCurrencyCode(string currencyCode) //check is this currency code valid

IsValidVIN(string vin) //check is string correct vin code

IsValidCardNumber(strign cardNumber) //check card number by Luhn algo

IsValidMAC(string mac) // is string valid mac address

IsValidMD5(string hash) // is string correct md5 hash

IsValidSHA256(string hash) // is string correct sha256 hash

IsValidHashtag(string hashtag) // is string valid hashtag format

IsValidPassport(string country, string passport) // check is passport correct for country
Product Compatible and additional computed target framework versions.
.NET 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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.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.0 165 2/22/2025
1.1.0 154 2/19/2025
1.0.0 160 2/18/2025