Fluentvalidation
Fluentvalidation is a data validation component that differs from the ASP. NET dataannotataion Attribute validation entity, providing a way to validate the separation of entities from validation, while Fluentvalidation also provides expressions Chained syntax.
Address:
Https://github.com/JeremySkinner/FluentValidation
Static voidMain (string[] args) { //non-null validationTestvalidator Validator =NewTestvalidator (v = v.rulefor (x =x.surname). Notnull ()); varResult= Validator. Validate (Newperson {Surname ="Foo"});//trueConsole.WriteLine (Result. IsValid); Result= Validator. Validate (Newperson {Surname =NULL});//falseConsole.WriteLine (Result. IsValid); Validator=NewTestvalidator {v= v.rulefor (x =x.surname). Notempty ()}; Result= Validator. Validate (Newperson {Surname =NULL }); Console.WriteLine (Result. IsValid); }
public class person { public string NameField; public int Id {get ; set public string Surname {get ; set public string forename {get ; set
Source code has many test examples
Verifying the component--fluentvalidation