Lyo.Validation
1.0.0
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
<PackageReference Include="Lyo.Validation" Version="1.0.0" />
<PackageVersion Include="Lyo.Validation" Version="1.0.0" />
<PackageReference Include="Lyo.Validation" />
paket add Lyo.Validation --version 1.0.0
#r "nuget: Lyo.Validation, 1.0.0"
#:package Lyo.Validation@1.0.0
#addin nuget:?package=Lyo.Validation&version=1.0.0
#tool nuget:?package=Lyo.Validation&version=1.0.0
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>andPropertyValidatorBuilder<T, TProperty>. - Attribute-based validation through built-in attributes such as
Required,NotEmpty,NotWhiteSpace,Length,Regex,Email,Phone,Uri, andRange(inLyo.Validation.Attributes). AttributeValidator<T>for reflection-driven validation across both Lyo'sValidationAttributeBaseandSystem.ComponentModel.DataAnnotations(includingIValidatableObject).- Structured property metadata via
ValidationMetadataKeys(PropertyName,AttemptedValue) attached to each failingError.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. RequiredAttribute → RequiredValue, EmailAddressAttribute → InvalidEmail,
RangeAttribute → OutOfRange); 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.Annotations5.0.0— (direct, microsoft)Microsoft.Extensions.Logging.Abstractions10.0.5— (transitive, microsoft)System.Memory4.6.3— (transitive, microsoft, netstandard2.0)System.Text.Json10.0.5— (transitive, microsoft, netstandard2.0)
| Product | Versions 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. |
-
.NETStandard 2.0
- Lyo.Common (>= 1.0.0)
- Lyo.Exceptions (>= 1.0.0)
- Lyo.Result (>= 1.0.0)
- System.ComponentModel.Annotations (>= 5.0.0)
-
net10.0
- Lyo.Common (>= 1.0.0)
- Lyo.Exceptions (>= 1.0.0)
- Lyo.Result (>= 1.0.0)
- System.ComponentModel.Annotations (>= 5.0.0)
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.