Danom.Validation 1.0.0-alpha1

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

// Install Danom.Validation as a Cake Tool
#tool nuget:?package=Danom.Validation&version=1.0.0-alpha1&prerelease                

Danom.Validation

NuGet Version build

One of the places the Results type really shines is input validation. It's a natural step in most workflows to validate input data before processing it, and the Result type is a great way to handle this. The Danom.Validation library provides a set of utilities to help with this and integrates with the wonderful FluentValidation library.

Getting Started

Install the Danom.Validation NuGet package:

PM>  Install-Package Danom.Validation

Or using the dotnet CLI

dotnet add package Danom.Validation

Quick Start

using Danom;
using Danom.Validation;
using FluentValidation;

public record Attendee(
    string Name,
    int Age,
    Option<string> Email,
    Option<string> AlternateEmail);

public class AttendeeValidator
    : AbstractValidator<Attendee>
{
    public AttendeeValidator()
    {
        RuleFor(x => x.Name).NotEmpty();
        RuleFor(x => x.Age).GreaterThan(0);
        RuleFor(x => x.Email).Required(x => x.EmailAddress());
        RuleFor(x => x.AlternateEmail).Optional(x => x.EmailAddress());
    }
}

var input =
    new Attendee(
        Name: "John Doe",
        Age: 30,
        Email: Option<string>.Some("john@doe.com"),
        AlternateEmail: Option<string>.None());

var result =
    ValidationResult<Attendee>
        .From<AttendeeValidator>(input);

result.Match(
    x => Console.WriteLine("Input is valid: {0}", x),
    e => Console.WriteLine("Input is invalid: {0}", e));
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 Danom.Validation:

Package Downloads
Danom.Mvc

ASP.NET Core MVC helpers for Danom.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0-beta1 52 10/11/2024
1.0.0-alpha1 61 8/30/2024