---
title: "TNValidate is now open source"
description: "TNValidate, a C# validation library with a fluent interface for defining validation rules, is now open source on GitHub. A short look at how to use it."
url: https://nestenius.se/net/tnvalidate-is-now-open-source/
date: 2017-08-01
author: "Tore Nestenius"
category: ".NET"
tags: ["developer-tools"]
site: https://nestenius.se/
---

# TNValidate is now open source

Our internal validation library TNValidate is now available as a project on [GitHub](https://github.com/tndataab/TNValidate). 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:

```csharp
// Instantiate validator.
var Validate = new Validator(ValidationLanguageEnum.English);

// Basic validation.
Validate.That(Email, "Email address").IsEmail();

// Chaining a couple of rules.
Validate.That(Name, "Name").IsLongerThan(3).IsShorterThan(100);

// Supply a custom error message.
Validate.That(Age, "Age").IsGreaterThanOrEqual(13, "You must be older than 13 to sign up");

// Check if validation succeeded.
if (Validate.HasErrors())
{
    // Show errors (Validate.ValidatorResults can be data-bound).
    foreach (var Error in Validate.ValidatorResults)
        Console.WriteLine(Error.ValidationMessage);
}
else
{
    // Was fine, continue...
    // ...
}
```

Head over to [GitHub](https://github.com/tndataab/TNValidate) and give it a try!

I have released other tools as open source too: the [Cloud Debugger for Azure](https://nestenius.se/azure/introducing-the-cloud-debugger-for-azure/), the [Data Protection API Key Ring Debugger](https://nestenius.se/net/introducing-the-data-protection-api-key-ring-debugger/) and the [Coding Agent Explorer](https://nestenius.se/ai/introducing-the-coding-agent-explorer-net/).

## Related posts

- [Discovering .NET codebases using code coverage and NCrunch](https://nestenius.se/net/discovering-net-codebases-using-code-coverage-and-ncrunch/)
- [Introducing the Data Protection API Key Ring Debugger](https://nestenius.se/net/introducing-the-data-protection-api-key-ring-debugger/)
- [Introducing the Coding Agent Explorer (.NET)](https://nestenius.se/ai/introducing-the-coding-agent-explorer-net/)
- [How to Use KurrentDB for Event Sourcing in C# on Azure](https://nestenius.se/net/how-to-use-kurrentdb-for-event-sourcing-in-c-on-azure/)
