Typely.AspNetCore
0.1.0-alpha
This is a prerelease version of Typely.AspNetCore.
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 Typely.AspNetCore --version 0.1.0-alpha
NuGet\Install-Package Typely.AspNetCore -Version 0.1.0-alpha
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="Typely.AspNetCore" Version="0.1.0-alpha" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Typely.AspNetCore --version 0.1.0-alpha
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Typely.AspNetCore, 0.1.0-alpha"
#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.
// Install Typely.AspNetCore as a Cake Addin #addin nuget:?package=Typely.AspNetCore&version=0.1.0-alpha&prerelease // Install Typely.AspNetCore as a Cake Tool #tool nuget:?package=Typely.AspNetCore&version=0.1.0-alpha&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Typely lets you create types easily with a fluent API to embrace Domain-driven design and value objects.
This library lets you use Typely in ASP.NET Core projects by providing validation exception handling and model binding.
Documentation
Usage
This middleware will catch any ValidationException
thrown by Typely and return a JSON response with the validation errors.
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
// Register this middleware before other middleware components
app.UseTypelyValidationResult();
Example of response:
{
"errorTemplates": {
"ZipCode": [
{
"code": "Matches",
"message": "'{Name}' is not in the correct format. Expected format '{RegularExpression}'.",
"typeName": "ZipCode",
"placeholderValues": {
"RegularExpression": "^((\\d{5}-\\d{4})|(\\d{5})|([A-Z|a-z]\\d[A-Z|a-z]\\d[A-Z|a-z]\\d))$",
"Name": "ZipCode",
"ActualLength": "7"
}
}
]
},
"errors": {
"ZipCode": [
"'ZipCode' is not in the correct format. Expected format '^((\\d{5}-\\d{4})|(\\d{5})|([A-Z|a-z]\\d[A-Z|a-z]\\d[A-Z|a-z]\\d))$'."
]
},
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "One or more validation errors occurred.",
"status": 400
}
If you need to add Typely's validation errors into the model state of MVC, use the model binder below:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers(options => options.UseTypelyModelBinderProvider());
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- Typely.Core (>= 1.2.5-alpha)
- Verify.Xunit (>= 19.14.0)
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 |
---|---|---|
8.0.0 | 102 | 6/8/2024 |
1.1.0 | 98 | 6/8/2024 |
1.0.2 | 166 | 10/12/2023 |
1.0.1 | 109 | 10/10/2023 |
1.0.0 | 143 | 9/24/2023 |
0.1.1 | 195 | 5/10/2023 |
0.1.1-alpha | 122 | 5/1/2023 |
0.1.0-alpha | 136 | 5/1/2023 |