Routya.ResultKit
1.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Routya.ResultKit --version 1.0.0
NuGet\Install-Package Routya.ResultKit -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="Routya.ResultKit" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Routya.ResultKit" Version="1.0.0" />
<PackageReference Include="Routya.ResultKit" />
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 Routya.ResultKit --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Routya.ResultKit, 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 Routya.ResultKit@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=Routya.ResultKit&version=1.0.0
#tool nuget:?package=Routya.ResultKit&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
📦 Routya.ResultKit
**Lightweight result wrapper and validation toolkit for C# **
Brings clean Result<T>
handling and extensible validation with custom attributes.
✨ Features
✅ Consistent Result<T>
response pattern
✅ One-line .Validate()
extension for request models
✅ Rich built-in and custom validation attributes
📥 Installation
dotnet add package Routya.ResultKit --version 1.0.0
🚀 Quick Start
1. Define Your Request Model (with Custom Validation)
using Routya.ResultKit.Attributes;
using System.ComponentModel.DataAnnotations;
private enum UserRole { Admin, User, Guest }
private class TestModel
{
[Required]
public string Name { get; set; }
[EmailAddress]
public string Email { get; set; }
[Range(18, 120)]
public int Age { get; set; }
[StringEnum(typeof(UserRole))]
public string Role { get; set; }
[Required]
public string Password { get; set; }
[Compare("Password")]
public string ConfirmPassword { get; set; }
public decimal MinPurchase { get; set; }
[GreaterThan("MinPurchase")]
public decimal MaxPurchase { get; set; }
}
2. Validate and Return
app.MapPost("/users", (CreateUserRequest request) =>
{
var validationResult = request.Validate();
if (!validationResult.Success)
return Results.BadRequest(validationResult);
return Results.Ok(Result.Ok(new { Id = 1 }));
});
✅ Successful Response Example
{
"Success": true,
"Data": {
"Name": "Henry",
"Email": "henry@example.com",
"Age": 30,
"Role": "Admin",
"Password": "abc123",
"ConfirmPassword": "abc123",
"MinPurchase": 100.0,
"MaxPurchase": 200.0
},
"Error": null
}
❌ Validation Error Response Example
{
"Success": false,
"Data": null,
"Error": {
"Title": "Validation Failed",
"Status": 400,
"Extensions": {
"errors": {
"Name": [
"The Name field is required."
],
"Email": [
"The Email field is not a valid e-mail address."
],
"Age": [
"The field Age must be between 18 and 120."
],
"Role": [
"Role must be one of: Admin, User, Guest"
],
"ConfirmPassword": [
"'ConfirmPassword' and 'Password' do not match."
],
"MaxPurchase": [
"MaxPurchase must be greater than MinPurchase"
]
}
}
}
}
🛠️ Built-in Validation Attributes
Routya.ResultKit includes powerful validation attributes ready to use:
Attribute | Purpose |
---|---|
[GreaterThan("OtherProp")] |
Ensure a property is greater than another |
[LessThan("OtherProp")] |
Ensure a property is less than another |
[RequiredIf("OtherProp", "Value")] |
Conditionally require a property |
[RequiredIfEmpty("OtherProp")] |
Require a property if another is empty |
[StringEnum(typeof(EnumType))] |
Ensure a string matches an Enum name |
[MatchRegex("pattern")] |
Validate a string against a regex |
[MinItems(count)] |
Validate minimum items in a collection |
[MaxItems(count)] |
Validate maximum items in a collection |
[ValidStartEndDateRange("Start", "End")] |
Validate that StartDate is before EndDate (This is a class level attribute) |
[ValidDateTimeOffsetRange("End")] |
Validate DateTimeOffset ranges |
[ValidDateTimeRange("End")] |
Validate DateTimeOffset ranges |
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 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 is compatible. |
.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.
-
.NETStandard 2.0
- System.ComponentModel.Annotations (>= 5.0.0)
-
.NETStandard 2.1
- System.ComponentModel.Annotations (>= 5.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.