As a developer I find the requirement for custom validation comes up a lot. Clients don't always like the validation that .NET MVC throws out by default; sometimes clients want validation added to field-types that MVC doesn't directly support or they might want to add further checks to the conditions surrounding a specific message displaying.
All of these are perfectly reasonable requests.
Expressive Annotations, built by Jaroslaw Waliszko, introduces the ability to add very simple annotation-based conditional validation to your models! Say goodbye to writing your own validation in the future, this library has you covered...
To add custom validation to a field you simply add the "RequiredIf" (for conditionally setting a field to be required) or the "AssertThat" (for checking statements are true/false) annotations to the necessary fields in your model along with the conditions you want it set against and you're done.
Naturally you are also able to add your own custom error messages, or pull them from resource files, by adding the ErrorMessage properties to your annotations.
For more detail and a wider look at the posibilities this library can offer, there's documentation on the Github page for the project: https://github.com/JaroslawWaliszko/ExpressiveAnnotations
You can add this into your projects right now - it's installable as a handy nuget package:
Or as a standalone DLL: