JKValidator 1.0.0

dotnet add package JKValidator --version 1.0.0                
NuGet\Install-Package JKValidator -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="JKValidator" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add JKValidator --version 1.0.0                
#r "nuget: JKValidator, 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.
// 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:

  1. Boolean
  2. DateTime
  3. Double
  4. Int
  5. Object
  6. String
  7. TimeSpan

Requirements:

  1. NET Core 3.1
  2. Visual Studio or VS Code

How to download:

  1. Go to Tools and select Manage Nuget Packages and Search for JKValidator library.
  2. OR Install-Package JKValidator -Version 1.0.1

For Depency Injection:

  1. Add IValidators on IServiceCollection in Startup.cs
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddScoped<IValidators, Validators>();
        }

For Static class:

  1. 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:

  1. .IsString(model.FirstName, "firstName", true)
  2. .IsString(model.FirstName, "firstName", true).Min(3).Max(10)
  3. .IsString(model.LastName, "@Test123", true).IsAlphaNumericSymbol()
  4. .IsString(model.LastName, "jk@gmail.com", true).IsEmail();
  5. .IsNumber(model.One, "one", true)
  6. .IsBool(model.IsTrue, "isTrue", true)
  7. .IsDateTime(model.DateTime, "dateTime", true)
  8. .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 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. 
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
1.0.0 475 1/16/2021