Gleeman.EffectiveValidator 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Gleeman.EffectiveValidator --version 1.0.0
                    
NuGet\Install-Package Gleeman.EffectiveValidator -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="Gleeman.EffectiveValidator" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Gleeman.EffectiveValidator" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Gleeman.EffectiveValidator" />
                    
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 Gleeman.EffectiveValidator --version 1.0.0
                    
#r "nuget: Gleeman.EffectiveValidator, 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 Gleeman.EffectiveValidator@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=Gleeman.EffectiveValidator&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Gleeman.EffectiveValidator&version=1.0.0
                    
Install as a Cake Tool

Gleeman Effective Validator

Nuget version Nuget downloads Build & Test Main

Validation Attributes

Credit Card Validation
[CheckCreditCard(CreditCardType creditCard, string errorMessage)]
Date Validation
[CheckDate(string startDate, string endDate, string errorMessage)]
Email Validation
 [CheckEmail(string errorMessage)]
Name Validation
  [CheckName(string errorMessage)]
Passport Validation
   [CheckPassport(string errorMessage)]
Phone Validation
    [CheckPhone(string errorMessage)]
Number Range Validation
     [CheckRange(int min, int max, string errorMessage)]
Required Validation
    [CheckRequired(string errorMessage)]
String Empty Validation
     [CheckStringEmpty(string errorMessage)]
String Lenght Validation
     [CheckStringLenght(int minLenght, int maxLenght, string errorMessage)]
Zip Code Validation
     [CheckZipCode(string errorMessage)]

How To Use?


public record CreatePersonDto
{
    [CheckName("is invalid!")]
    [CheckStringLenght(3, 10, "should be between 3 and 10 characters!")]
    public string FirstName { get; init; }

    [CheckName("is invalid")]
    [CheckStringEmpty("should not be empty!")]
    public string LastName { get; init; }

    [CheckDate("1950/1/1", "2005/1/1", "is invalid!")]
    public DateTime DateOfBirth { get; init; }

    [CheckRange(18, 73, "is invalid!")]
    public int Age { get; init; }

    [CheckEmail("is invalid!")]
    public string Email { get; init; }

    [CheckPhone("is invalid")]
    public string PhoneNumber { get; init; }

    [CheckPassport("is invalid!")]
    public string PassportNumber { get; init; }

    [CheckCreditCard(CreditCardType.Visa, "is invalid!")]
    public string CreditCartNumber { get; init; }

    [CheckZipCode("is invalid!")]
    public string ZipCode { get; init; }

    [CheckRequired("is required!")]
    public bool? IsActive { get; init; }
}

var validator = new EffectiveValidator<CreatePersonDto>();
var validationResult = validator.Validate(createPerson);
if (validationResult.IsValid)
 {
     using var dbContext = new AppDbContext();
     dbContext.Persons.Add(person);
     dbContext.SaveChanges();
     return Created("", createPerson);
}
return BadRequest(validationResult.ErrorMessages);


Product 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.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.

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
2.0.0 235 9/21/2023
1.0.0 240 9/9/2023