QuickInputValidation 1.0.0
dotnet add package QuickInputValidation --version 1.0.0
NuGet\Install-Package QuickInputValidation -Version 1.0.0
<PackageReference Include="QuickInputValidation" Version="1.0.0" />
paket add QuickInputValidation --version 1.0.0
#r "nuget: QuickInputValidation, 1.0.0"
// Install QuickInputValidation as a Cake Addin
#addin nuget:?package=QuickInputValidation&version=1.0.0
// Install QuickInputValidation as a Cake Tool
#tool nuget:?package=QuickInputValidation&version=1.0.0
Quick Custom Input Validation for Web API V1.0
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
This package has 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 |
---|---|---|
1.0.0 | 1,681 | 9/8/2015 |
Sample to code to use QuickValidation -
static void Main(string[] args)
{
var customer = new Customer { Id = 0, LegalIdentifier = "S12" };
var customerValidationFor = new CustomerValidator { StopToContinue = true };
var result = customerValidationFor.Validate(customer);
if (!result.IsValid)
{
Console.WriteLine(result.ErrorMessage);
Console.ReadLine();
return;
};
Console.WriteLine("Validate successfully");
Console.ReadLine();
}
public class CustomerValidator : BaseValidationFor<Customer>
{
public CustomerValidator()
{
ValidationFor()
.ShouldBe(item => item.Id > 0, item => string.Format("Customer id {0} should not valid", item.Id))
.ShouldBe(item => item.LegalIdentifier.NotNull(), "it should not be null")
.ShouldBe(item => item.LegalIdentifier.NotEmpty())
.ShouldBe(item => item.Name.NotEmpty(), item => "Customer name should not be empty.")
.ShouldBe(item => item.LegalIdentifier.IsNumber(), item => string.Format("{0} should be a number", item.LegalIdentifier))
.ShouldBe(item => item.LegalIdentifier.Length(2), item => string.Format("{0} should be 2 characters long", item.LegalIdentifier));
}
}