Swallow.Validation 8.0.0

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

// Install Swallow.Validation as a Cake Tool
#tool nuget:?package=Swallow.Validation&version=8.0.0                

Swallow.Validation

Swallow.Validation is a lightweight, fluent-style validation library for C#. But what does that mean? It means minimal dependencies (none, actually) and great developer experience. If you've seen Fluent Assertions, you might find some similarities.

Usage

Package Description
Swallow.Validation The "batteries included" version containing the underlying validation engine and a collection of useful assertions for your day-to-day usage.
Swallow.Validation.Core The bare validation engine without any assertions at all. Useful when you want to have complete control over the actual validation going on.
Swallow.Validation.ServiceCollection Adapter to discover and register asserters in a ValidationContainer inside a service collection.

Features

Swallow.Validation does not require a separate class to contain the validation logic - you can just drop it right into your code without problems. This allows you to enforce invariants rather than validate the state of entities; instead of constructing a person and checking whether it is correct, you can make sure that no person created can ever be in an invalid state - without needing to remember calling new PersonValidator().Validate(myPerson).

The library is also "natively extensible", meaning you can create custom validation rules that perfectly blend in together with the predefined validation rules and the fluent style. You can create rules matched for your problem domain and use your own ubiquitous language. With the fluent style of the library, you can formulate validation rules directly in your domain language.

Validator.Check()
    .That(Country).IsValidIsoCode()
    .That(DeliveryDate).IsAfter(DateTime.UtcNow)
    .That(Items).IsNotNull().IsNotEmpty()
    .ElseThrow()

Additionally, the validation errors are strongly typed. Instead of throwing around strings everywhere, you have meaningful errors containing properties to describe the problem in an exact manner. You also need not worry about wording your error messages when doing your validation. You can also easily test validation logic this way; instead of comparing strings, you can just check if the error is of the correct type. You can even localize the error messages if you'd like; that way, the validation errors can even be given directly to the user.

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Swallow.Validation:

Package Downloads
Swallow.Validation.ServiceCollection

A lightweight, fluent and extensible validation library that allows you to specify validations right where you need them. No extra classes needed, strongly typed errors and extensibility built right into the core.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.0.0 70 11/25/2024
7.0.0 2,090 1/20/2024
6.0.1 1,102 7/2/2023
6.0.0 2,128 1/22/2023
5.0.1 747 11/13/2022
4.2.0 873 6/20/2022
4.1.1 618 5/29/2022
4.1.0 803 2/13/2022
4.0.0 550 2/13/2022
3.1.0 22,360 6/5/2021
3.0.0 466 5/20/2021
2.0.0 488 3/6/2021
1.5.0 2,260 11/23/2020
1.4.0 447 9/4/2020
1.3.0 621 7/20/2020
1.2.0 1,408 6/4/2020
1.1.1 496 5/9/2020
1.1.0 475 5/5/2020
1.0.0 580 4/29/2020
0.12.3 515 4/5/2020
0.12.2 478 4/3/2020
0.12.1 11,278 3/16/2020
0.12.0 508 3/14/2020
0.11.2 585 2/29/2020
0.11.1 557 2/16/2020
0.11.0 535 2/13/2020
0.10.3 526 2/12/2020
0.10.2 580 1/31/2020
0.10.1 535 1/27/2020
0.10.0 540 1/5/2020
0.9.1 488 1/3/2020
0.8.0 486 12/21/2019
0.7.3 4,954 11/27/2019
0.7.2 493 11/9/2019
0.7.1 483 11/9/2019
0.7.0 509 11/9/2019
0.6.1 490 10/27/2019
0.5.3 494 10/23/2019
0.5.2 484 10/21/2019
0.5.1 482 10/20/2019
0.4.2 517 9/14/2019
0.4.1 513 9/7/2019
0.3.3 517 9/7/2019
0.3.2 562 8/28/2019
0.3.1 536 8/24/2019
0.2.4 507 8/24/2019
0.2.3 583 8/24/2019