Gleeman.EffectiveValidator 2.0.0

dotnet add package Gleeman.EffectiveValidator --version 2.0.0                
NuGet\Install-Package Gleeman.EffectiveValidator -Version 2.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="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Gleeman.EffectiveValidator --version 2.0.0                
#r "nuget: Gleeman.EffectiveValidator, 2.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 Gleeman.EffectiveValidator as a Cake Addin
#addin nuget:?package=Gleeman.EffectiveValidator&version=2.0.0

// Install Gleeman.EffectiveValidator as a Cake Tool
#tool nuget:?package=Gleeman.EffectiveValidator&version=2.0.0                

Gleeman Effective Validator

| Package | Version | Popularity | | ------- | ----- | ----- | | Gleeman.EffectiveValidator | NuGet | Nuget <br>

dotnet CLI

> dotnet add package Gleeman.EffectiveValidator --version 2.0.0

Validation Attributes

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

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; }
}

        [HttpPost]
        public IActionResult PostPerson(CreatePersonDto createPerson)
        {
            Person person = new()
            {
                FirstName = createPerson.FirstName,
                LastName = createPerson.LastName,
                DateOfBirth = createPerson.DateOfBirth,
                Age = createPerson.Age,
                Email = createPerson.Email,
                PhoneNumber = createPerson.PhoneNumber,
                CreditCartNumber = createPerson.CreditCartNumber,
                PassportNumber = createPerson.PassportNumber,
                ZipCode = createPerson.ZipCode,
                IsActive = createPerson.IsActive
            };

            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. 
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 142 9/21/2023
1.0.0 150 9/9/2023

Field validation feature was added.