Danom.Validation
1.0.0-beta1
See the version list below for details.
dotnet add package Danom.Validation --version 1.0.0-beta1
NuGet\Install-Package Danom.Validation -Version 1.0.0-beta1
<PackageReference Include="Danom.Validation" Version="1.0.0-beta1" />
paket add Danom.Validation --version 1.0.0-beta1
#r "nuget: Danom.Validation, 1.0.0-beta1"
// Install Danom.Validation as a Cake Addin #addin nuget:?package=Danom.Validation&version=1.0.0-beta1&prerelease // Install Danom.Validation as a Cake Tool #tool nuget:?package=Danom.Validation&version=1.0.0-beta1&prerelease
Danom.Validation
One of the places the Result
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, integrating 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
Example
The kitchen sink example below demonstrates the functionality delivered from this slim library built on top of Danom.
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 | Versions 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. |
-
net8.0
- Danom (>= 1.0.0-beta1)
- FluentValidation (>= 11.10.0)
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 | 99 | 11/20/2024 |
1.0.0-beta1 | 87 | 10/11/2024 |
1.0.0-alpha1 | 98 | 8/30/2024 |