SimpleValidationLibrary 6.1.0

dotnet add package SimpleValidationLibrary --version 6.1.0
                    
NuGet\Install-Package SimpleValidationLibrary -Version 6.1.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="SimpleValidationLibrary" Version="6.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SimpleValidationLibrary" Version="6.1.0" />
                    
Directory.Packages.props
<PackageReference Include="SimpleValidationLibrary" />
                    
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 SimpleValidationLibrary --version 6.1.0
                    
#r "nuget: SimpleValidationLibrary, 6.1.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 SimpleValidationLibrary@6.1.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=SimpleValidationLibrary&version=6.1.0
                    
Install as a Cake Addin
#tool nuget:?package=SimpleValidationLibrary&version=6.1.0
                    
Install as a Cake Tool

Simple Validation Library

A lightweight .NET library for validating emails, region-aware phone numbers, dates, and custom regex-based rules — with clear, typed exceptions instead of boolean guesswork.

Features

  • Email validation — IsValidEmail
  • Phone number validation with regional rules (USA, UK, Spain, Ireland) — IsValidPhoneNumber
  • Postal code validation with regional rules (USA, UK, Spain, Ireland) — IsValidPostalCode
  • Date validation — IsValidDate
  • URL validation (http/https) — IsValidUrl
  • Credit card number validation (Luhn checksum) — IsValidCreditCardNumber
  • Password strength validation (configurable rules) — IsValidPassword
  • IP address validation (IPv4 and IPv6) — IsValidIPAddress
  • Numeric range validation — IsInRange
  • String length validation — IsValidLength
  • Custom validations — register your own named regex rules via IsValidCustom
  • Typed exceptions (ValidationException, UnsupportedRegionException) for precise error handling

Installation

dotnet add package SimpleValidationLibrary

Usage

using ValidationLibrary;

// Email
Validator.IsValidEmail("user@example.com"); // returns true, or throws Validator.ValidationException

// Phone number (region-aware)
Validator.IsValidPhoneNumber("612345678", RegionEnum.Region.Spain);

// Postal code (region-aware)
Validator.IsValidPostalCode("28001", RegionEnum.Region.Spain);

// Date
Validator.IsValidDate("2026-01-15");

// URL
Validator.IsValidUrl("https://example.com");

// Credit card number (Luhn checksum)
Validator.IsValidCreditCardNumber("4111 1111 1111 1111");

// Password strength (configurable)
Validator.IsValidPassword("Str0ng!Pass");
Validator.IsValidPassword("simplepass", minLength: 6, requireUppercase: false, requireDigit: false, requireSpecialChar: false);

// IP address (IPv4 or IPv6)
Validator.IsValidIPAddress("192.168.1.1");

// Numeric range
Validator.IsInRange(5, 1, 10);

// String length
Validator.IsValidLength("hello", 1, 10);

// Custom rule
Validator.CustomValidations["digits-only"] = @"^\d+$";
Validator.IsValidCustom("12345", "digits-only");

Handling validation errors

try
{
    Validator.IsValidEmail("not-an-email");
}
catch (Validator.ValidationException ex)
{
    Console.WriteLine(ex.Message); // "Invalid email."
}

Requirements

  • .NET 8.0, 9.0, or 10.0

Source & issues

https://github.com/AdrianBailador/SimpleValidationLibrary

License

MIT

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 is compatible.  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 is compatible.  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.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.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.

Now multi-targets net8.0, net9.0, and net10.0 (was net10.0-only). Same 6.0.0 rewrite otherwise: migrated off the legacy, deprecated 5.0.0 release, fixed PackageId resolving to an empty string, aligned namespaces, added full test coverage, and added IsValidPostalCode (region-aware), IsValidUrl, IsValidCreditCardNumber (Luhn check), IsValidPassword, IsValidIPAddress, IsInRange, and IsValidLength.