Many.Validators 1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package Many.Validators --version 1.0.3                
NuGet\Install-Package Many.Validators -Version 1.0.3                
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="Many.Validators" Version="1.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Many.Validators --version 1.0.3                
#r "nuget: Many.Validators, 1.0.3"                
#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 Many.Validators as a Cake Addin
#addin nuget:?package=Many.Validators&version=1.0.3

// Install Many.Validators as a Cake Tool
#tool nuget:?package=Many.Validators&version=1.0.3                

Many.Validators

A set of very-easy-to-read immutable types to add seamless validations in your projects.

I focused on:

  • Less documentation, better code legibility.
  • No extra line of code.
  • [Extremely] easy integration.
  • Minimum overhead compared to traditional copy-pasted-conditionals way or any other implementation.

👉Download releases at https://www.nuget.org/packages/Many.Validators/

Features

NetStandard 2.1 and NET60 specific implementations

  • New Half type support for NET5 and NET6 projects.

Built-int validators and features

Validator Implemented Overhead* (baseline=1) Version
NotNull<> 4.3 1.0.0
NotNullOrEmpty< string> 1.4 1.0.0
Positive<> 1.3 - 2.1 1.0.0
PositiveOrZero<> 1.3 - 2.1 1.0.0
Negative<> 1.3 - 2.1 1.0.0
NegativeOrZero<> 1.3 - 2.1 1.0.0

<sub>(*) This column shows the average overhead calculation in the validation-passes scenario that is the most expensive: we need to perform a validation and it passes. This is a measure of the overhead cost, not the cost itself. <br/>The baseline corresponds to the simplest way to validate each case (copy-pasted IF conditional(s) and manual exception throwing). Data is provided from supported frameworks but in this table the value is from NET60 benchmarks. <br>Results for older frameworks can vary depending the framework (generally older the framework a bit worse the result) and if you force conversions or not (you can check the complete results at Many.Validators.Benchmark/Data).</sub>

Feature Implemented Version
Validators concatenation ?

Two-way conversion between validator and underlying types

NotNull<string> notMullStringValidator = "whatever"; //Ok
string x = notMullStringValidator; //Ok

notMullStringValidator.Equals(x); //true!

Seamless integration

Use validators in your methods referring your underlying type:

bool WhateverMethod(NotNull<string> @param)
{
    //@param is observed and validated when is instantiated. 
    //If validation fails no line of code will be run in this method

    Console.WriteLine("Whatever");
    
    //Gets @param value with no conversion
    return !string.IsNullOrWhiteSpace(@param); 
}

And call your methods as usual with no additional conversions:

string p;

<Code where you can assign a value to p or not...>

var result = WhateverMethod(p);

<Continues if no exception was raised...>

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  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 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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
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.
  • .NETFramework 4.7.2

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • All Frameworks

  • 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.

v.1.0.3
- NotNull, NotEmpty, Positive, PositiveOrZero, Negative and NegativeOrZero validators.