Nestgrid.Response.Extensions.Validation 0.8.0

dotnet add package Nestgrid.Response.Extensions.Validation --version 0.8.0
                    
NuGet\Install-Package Nestgrid.Response.Extensions.Validation -Version 0.8.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="Nestgrid.Response.Extensions.Validation" Version="0.8.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nestgrid.Response.Extensions.Validation" Version="0.8.0" />
                    
Directory.Packages.props
<PackageReference Include="Nestgrid.Response.Extensions.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 Nestgrid.Response.Extensions.Validation --version 0.8.0
                    
#r "nuget: Nestgrid.Response.Extensions.Validation, 0.8.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 Nestgrid.Response.Extensions.Validation@0.8.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=Nestgrid.Response.Extensions.Validation&version=0.8.0
                    
Install as a Cake Addin
#tool nuget:?package=Nestgrid.Response.Extensions.Validation&version=0.8.0
                    
Install as a Cake Tool

Nestgrid.Response.Extensions.Validation

Data annotations validation extensions for Nestgrid.Response.

Nestgrid.Response.Extensions.Validation converts System.ComponentModel.DataAnnotations.ValidationResult values into Nestgrid result messages and invalid results.

Installation

dotnet add package Nestgrid.Response.Extensions.Validation

Quick Start

using System.ComponentModel.DataAnnotations;
using Nestgrid.Response;
using Nestgrid.Response.Extensions.Validation;

var validationResults = new List<ValidationResult>();

Validator.TryValidateObject(
    request,
    new ValidationContext(request),
    validationResults,
    validateAllProperties: true);

Result result = validationResults.ToInvalidResult();

Realistic Example

using System.ComponentModel.DataAnnotations;
using Nestgrid.Response;
using Nestgrid.Response.Extensions.Validation;

public Result<UserDto> Create(CreateUserRequest request)
{
    var validationResults = new List<ValidationResult>();

    if (!Validator.TryValidateObject(
        request,
        new ValidationContext(request),
        validationResults,
        validateAllProperties: true))
    {
        return validationResults.ToInvalidResult<UserDto>();
    }

    var user = new UserDto(1, request.Name, request.Email);

    return Results.Created(user);
}

Feature Summary

  • Converts one ValidationResult to one ResultMessage.
  • Converts many validation results to result messages.
  • Creates non-generic and generic invalid results.
  • Allows caller-selected message severity.
  • Preserves validation message text exactly as supplied.
  • Does not introduce a custom validation abstraction.
  • Provides opt-in member-aware conversion through ToMessagesWithProperties() and ToInvalidResultWithProperties<T>().

Behavior

  • Validation messages are preserved exactly as supplied.
  • Member names are not prepended to messages.
  • Message codes are not inferred.
  • Message properties are not inferred.
  • Default severity is Warning.
  • ToInvalidResult() always returns ResultStatus.Invalid.

Member-aware conversion is opt-in and preserves member names as ResultMessage.Property values. Blank member names are ignored; a validation result without a usable member produces one memberless message. The default code is validation_failed, the default message for a missing error message is The entity is invalid., and the default severity remains Warning.

Validation messages, property names and custom codes are consumer-controlled output. Review them before returning them to untrusted clients or writing them to logs; the package does not decide whether a particular domain validation message is safe to disclose.

var result = validationResults.ToInvalidResultWithProperties<UserDto>();

Override severity when needed:

var result = validationResults.ToInvalidResult(ResultMessageSeverity.Error);

Documentation

Samples

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 was computed.  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

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
0.8.0 81 8/28/2026
0.7.0 94 8/18/2026
0.6.0 110 7/20/2026
0.5.0 129 6/26/2026