Lyo.Validation 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Lyo.Validation --version 1.0.0
                    
NuGet\Install-Package Lyo.Validation -Version 1.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="Lyo.Validation" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Lyo.Validation" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Lyo.Validation" />
                    
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 Lyo.Validation --version 1.0.0
                    
#r "nuget: Lyo.Validation, 1.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.
#:package Lyo.Validation@1.0.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=Lyo.Validation&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Lyo.Validation&version=1.0.0
                    
Install as a Cake Tool

Lyo.Validation

Lyo.Validation contains reusable C# validators, fluent rule builders, validation attributes, and adapters that return structured Lyo.Result.Result<T> failures. Errors are populated through Lyo.Result.Error so callers can render Problem Details, log structurally, or aggregate into BulkResult.

Examples

Typical usage

using Lyo.Validation;

var validator = ValidatorBuilder<CreateUserRequest>.Create()
    .RuleFor(x => x.Name)
    .NotWhiteSpace()
    .Length(2, 50)
    .RuleFor(x => x.Email)
    .Email()
    .RuleFor(x => x.Age)
    .InclusiveBetween(18, 120)
    .Build();

var result = validator.Validate(new CreateUserRequest { Name = "Matt", Email = "matt@example.com", Age = 33 });

Attribute-based validation

public sealed class CreateUserRequest {
    [NotWhiteSpace]
    [Length(2, 50)]
    public string Name { get; init; } = string.Empty;

    [Email]
    public string Email { get; init; } = string.Empty;

    [Range(18, 120)]
    public int Age { get; init; }
}

Result<CreateUserRequest> result = new CreateUserRequest { /* ... */ }.ValidateWithAttributes();

What lives here

  • Fluent validator composition via ValidatorBuilder<T> and PropertyValidatorBuilder<T, TProperty>.
  • Attribute-based validation through built-in attributes such as Required, NotEmpty, NotWhiteSpace, Length, Regex, Email, Phone, Uri, and Range (in Lyo.Validation.Attributes).
  • AttributeValidator<T> for reflection-driven validation across both Lyo's ValidationAttributeBase and System.ComponentModel.DataAnnotations (including IValidatableObject).
  • Structured property metadata via ValidationMetadataKeys (PropertyName, AttemptedValue) attached to each failing Error.Metadata.
  • Stable error codes via Lyo.Result.ValidationErrorCodes (e.g. NullValue, EmptyValue, InvalidLength, InvalidEmail, OutOfRange, ValidationFailed).

Attribute-based validation

AttributeValidator<T> reads validation attributes from T's public, instance-readable properties (compiled property getters are cached statically per T). It composes Lyo's own ValidationAttributeBase attributes with System.ComponentModel.DataAnnotations.ValidationAttribute, and — when T implements IValidatableObject — also runs Validate(ValidationContext). AttributeValidator<T>.Shared exposes a cached singleton; convenience extension value.ValidateWithAttributes() calls it.

DataAnnotations error codes are mapped onto Lyo.Result.ValidationErrorCodes (e.g. RequiredAttributeRequiredValue, EmailAddressAttributeInvalidEmail, RangeAttributeOutOfRange); anything not mapped falls back to ValidationFailed.

Dependencies

Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).

  • Lyo.Common — (direct, lyo)
  • Lyo.Exceptions — (direct, lyo)
  • Lyo.Result — (direct, lyo)
  • System.ComponentModel.Annotations 5.0.0 — (direct, microsoft)
  • Microsoft.Extensions.Logging.Abstractions 10.0.5 — (transitive, microsoft)
  • System.Memory 4.6.3 — (transitive, microsoft, netstandard2.0)
  • System.Text.Json 10.0.5 — (transitive, microsoft, netstandard2.0)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Lyo.Validation:

Package Downloads
Lyo.Web.Components

Blazor components library for the Lyo web UI framework with MudBlazor integration.

Lyo.Api

Core API library for building RESTful APIs with Entity Framework Core, caching, and mapping support.

Lyo.Validation.Postgres

PostgreSQL persistence for Lyo.Validation schemas (WhereClause JSONB) using Entity Framework Core.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.9 0 8/22/2026
1.0.6 157 8/20/2026
1.0.4 298 8/20/2026
1.0.3 244 8/19/2026
1.0.2 277 8/19/2026
1.0.1 342 8/18/2026
1.0.0 377 8/16/2026