Our internal validation library TNValidate is now available as a project on GitHub. We released this as open source because we wanted to let others take part in our internal libraries. The library is written in C# and uses a “Fluent Interface” to define the validation rules.
By using TNValidate, we have achieved a uniform way to write our validation logic, which in turn has reduced the number of bugs and made our code more readable.
Using TNValidate is very simple:
// Instantiate validator.
var Validate = new Validator(ValidationLanguageEnum.English);
// Basic validation.
Validate.That(Email, "Email address").IsEmail();
// Chaining a couple of rules.
// Supply a custom error message.
"You must be older than 13 to sign up");
// Check if validation succeeded.
// Show errors (Validate.ValidatorResults can be data-bound).
foreach (var Error in Validate.ValidatorResults)
// Was fine, continue...
Head over to GitHub and give it a try!