FailOr.Validations
1.1.0
dotnet add package FailOr.Validations --version 1.1.0
NuGet\Install-Package FailOr.Validations -Version 1.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="FailOr.Validations" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FailOr.Validations" Version="1.1.0" />
<PackageReference Include="FailOr.Validations" />
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 FailOr.Validations --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FailOr.Validations, 1.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 FailOr.Validations@1.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=FailOr.Validations&version=1.1.0
#tool nuget:?package=FailOr.Validations&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
FailOr.Validations
FailOr.Validations is the typed companion package for property-based validation on plain T values. It builds on top of FailOr and adds selector-driven validation and validation-plus-transform helpers.
Install
dotnet add package FailOr.Validations
FailOr.Validations depends on FailOr, so the core package is restored automatically.
Behavior
Validate(...)andValidateAsync(...)run one or more property-based validators and return the original input instance on success.ValidateThenTransform(...)andValidateThenTransformAsync(...)run one or more property-based mappers and invoke the final transform only when every mapper succeeds.- Only
Failures.Validationinstances are rewritten to the selected leaf property name such asNameorCity. Failures.GeneralandFailures.Exceptionalare preserved unchanged.- Async validators and async mappers run sequentially and preserve declaration order.
Quick Start
Validate and keep the original value:
using FailOr;
using FailOr.Validation;
var person = new Person
{
Name = "Ada",
Nickname = "Ace",
Address = new Address { City = "Boston" }
};
var result = person.Validate(
(x => x.Name, name => string.IsNullOrWhiteSpace(name)
? FailOr.Fail<int>(Failure.Validation("Ignored", "Name is required."))
: FailOr.Success(1)),
(x => x.Address.City, city => string.IsNullOrWhiteSpace(city)
? FailOr.Fail<int>(Failure.Validation("Ignored", "City is required."))
: FailOr.Success(1)));
Map selected properties and transform the mapped values:
using FailOr;
using FailOr.Validation;
var result = person.ValidateThenTransform(
(x => x.Name, name => string.IsNullOrWhiteSpace(name)
? FailOr.Fail<string>(Failure.Validation("Ignored", "Name is required."))
: FailOr.Success(name.ToUpperInvariant())),
(x => x.Address.City, city => string.IsNullOrWhiteSpace(city)
? FailOr.Fail<string>(Failure.Validation("Ignored", "City is required."))
: FailOr.Success(city.ToUpperInvariant())),
(name, city) => $"{name}|{city}");
Run async validators and async transforms:
using FailOr;
using FailOr.Validation;
var result = await person.ValidateThenTransformAsync(
(x => x.Name, async name =>
{
await Task.Delay(1);
return string.IsNullOrWhiteSpace(name)
? FailOr.Fail<string>(Failure.Validation("Ignored", "Name is required."))
: FailOr.Success(name.ToUpperInvariant());
}),
async name =>
{
await Task.Delay(1);
return $"Hello {name}";
});
Documentation
- Repository overview: FailOr root README
- Core package readme: src/FailOr/README.md
- Validations API reference: docs/validations-api-reference.md
License
Licensed under the MIT License. See LICENSE.
| 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. 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 is compatible. 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.
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 |
|---|---|---|
| 1.1.0 | 100 | 3/15/2026 |