JKValidator 1.0.0
dotnet add package JKValidator --version 1.0.0
NuGet\Install-Package JKValidator -Version 1.0.0
<PackageReference Include="JKValidator" Version="1.0.0" />
paket add JKValidator --version 1.0.0
#r "nuget: JKValidator, 1.0.0"
// Install JKValidator as a Cake Addin #addin nuget:?package=JKValidator&version=1.0.0 // Install JKValidator as a Cake Tool #tool nuget:?package=JKValidator&version=1.0.0
JKValidator NuGet Library
JKValidator is a simple C# properties validator.
Behind JKValidator:
JK stands for JOEVER and KEVIN , Kevin initially started the code implementation on 2018, together with Joever.
The inspiration of this validator is to eradicate the old school way of validating the property
and to create standard property validator for Microsoft.
We want to help developers who wants to change or improve their way of validating the properties, so we decide to publish this library on nuget.
NuGet: https://www.nuget.org/packages/JKValidator/
Usability:
JKValidator supported both dependecy injection and static method way of implementations. Available Property Validators:
- Boolean
- DateTime
- Double
- Int
- Object
- String
- TimeSpan
Requirements:
- NET Core 3.1
- Visual Studio or VS Code
How to download:
- Go to Tools and select Manage Nuget Packages and Search for JKValidator library.
- OR Install-Package JKValidator -Version 1.0.1
For Depency Injection:
- Add IValidators on IServiceCollection in Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddScoped<IValidators, Validators>();
}
For Static class:
- Just simply instantiate the Validators inside your method.
public static ValidationError Test()
{
Validators v = new Validators();
v.IsString("JK", "object", true);
if (v.ContainsError())
return v.AsValidationError();
return null;
}
Validator methods:
- .IsString(model.FirstName, "firstName", true)
- .IsString(model.FirstName, "firstName", true).Min(3).Max(10)
- .IsString(model.LastName, "@Test123", true).IsAlphaNumericSymbol()
- .IsString(model.LastName, "jk@gmail.com", true).IsEmail();
- .IsNumber(model.One, "one", true)
- .IsBool(model.IsTrue, "isTrue", true)
- .IsDateTime(model.DateTime, "dateTime", true)
- .IsObject(model.Object, "object", true)
Results
{
"statusCode": 400,
"title": "Validation Failed",
"message": "The form contains invalid fields",
"payload": [
{
"name": "lastName",
"errors": [
"Property is required and must be set."
]
}
],
"tag": null,
"type": "Error"
}
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. |
.NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- Microsoft.AspNetCore.Mvc.Core (>= 2.2.5)
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 |
---|---|---|
1.0.0 | 467 | 1/16/2021 |