Validatum

Validatum is an open-source library for building fluent validation functions for .NET.

Platform Support

  • .NET Standard 2.0+
  • .NET Core 2.0+
  • .NET Framework 4.6.1+

Example

var validator = new ValidatorBuilder<Employee>()
    .Required(e => e.FirstName)
    .Email(e => e.Email)
    .For(e => e.LastName, name =>
    {
        name.MinLength(5)
            .Equal("Smithers");
    })
    .Build();

var result = validator.Validate(
    new Employee 
    { 
        LastName = "Simpson",
        Email = "homer[at]springfieldnuclear.com"
    }
);

foreach (var rule in result.BrokenRules)
{
    Console.WriteLine($"[{rule.Rule}] {rule.Key}: {rule.Message}");
}

The example will produce the output:

[Required] FirstName: Value is required.
[Email] Email: Value must be a valid email.
[Equal] LastName: Value must equal 'Smithers'.

Getting Started