SimpleDataValidation 0.1.0

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

What is SimpleDataValidation?

SimpleDataValidation is an open-source .NET library for validating data in a simple and intuitive way.

It's written in C#/NET8 with VS2026. The code is covered by 13 unit tests to ensure the non-regression of incoming evolutions.

A quick example

The usage is very simple, you just need to call the static method of the V class, passing the name of the data and its value.

Syntax:
string errMsg = V.Function(DataName, Value);
If the validation fails  -> The error message is returned in the errMsg variable. 
If the validation passes -> An empty string is returned.

The following example shows how to use the library to validate a string value to check if it's not null.

using SimpleDataValidation;

// Validate a string value to check if it's not null
errMsg = V.MinLength("Name", "John", 8);
Console.WriteLine($"-> errorMessage: {errMsg}");   

// will display the following error message:
-> errorMessage: Name must be at least 8 characters long

Another way to use the library

You can also use the library in a more fluent way, by chaining the validation methods to validate a data value many times.

// Validate a string value to check if it's not null and has a minimum length of 8 characters
errMsg = V.Define("Name", "John").AddNotNull().AddMinLength(8).Validate();

Start by calling the static method Define of the V class, passing the name of the data and its value. Then, you can chain the validation methods to validate the data value many times. Finally, call the Validate method to perform the validation and return the error message if any.

Features

There are many available features to validate data, by type, by length, and by format.

Available validation methods

// List of available direct validation methods:
NotNull:             Check that the object value is not null.
NotNullOrEmpty:      Check that the string value is not empty.
NotNullOrWhiteSpace: Check that the string value is not whitespace.
MinLength:           Check that the string value has a minimum length.
MaxLength:           Check that the string value has a maximum length.
ExactLength:         Check that the string value has an exact length.
Email:               Check that the string value is a valid email address.
Int:                 Check that the object value is an integer.
Iban:                Check that the string value is a valid IBAN number.

// List of available chained validation methods:
AddNotNull  
AddMinLength
AddMaxLength

Error Messages

Today only english and french are supported for error messages, but other languages will be added in the future.

But you can also set your own error messages for each validation method, by passing the error message as a parameter to the validation method.

string nameValue = null;
errMsg = V.NotNull("Name",nameValue, "The name is mandatory!");
Console.WriteLine($"-> errorMessage: {errMsg}");

// will display the following error message:
-> errorMessage: The name is mandatory!

The default language for error messages is English, but you can change it to French by calling the SetLanguage method of the V class, passing the language code as a parameter.

// Set the language for error messages to French
V.SetLanguage("fr-fr");

You can also set the end of the error message with a dot or not, by calling the SetEndMessageDot method of the V class, passing a boolean value as a parameter.

V.SetEndMessageDot();
exp: The name is required.

Or put something else:

V.SetEndMessage("!");
exp: The name is required!

Source code, documentation and nuget

SimpleDataValidation library is packaged as a nuget ready to use:

https://www.nuget.org/packages/SimpleDataValidation

Github source repository:

https://github.com/Pierlam/SimpleDataValidation/

Contact

Have a comment to do? A question to ask? Want to request a new feature?

Don't hesitate to send me an email:

pierlam-project@outlook.com

Resources

A dotnet well-known data validation library: https://docs.fluentvalidation.net/en/latest/index.html

Iban validation: https://medium.com/@matlabb/iban-structure-and-mod-97-validation-algorithm-719e3d4db5f2

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
0.1.0 51 10/10/2026

First version of the library.