Entity.Validation is demonstrated with WPF MVVM pattern. Basically this framework help to validate entity properties based on Attribute decorated. In a simple terms something closer to DataAnnotation in MVC. This Framework uses FluentValidation (https://fluentvalidation.codeplex.com/) library internally.

Usage-Example

Entity Side

public class Person : ValidateEntity<Person>
{
public override Person Instance
{
get { return this; }
}

ValidateField(IsRequired = true)
public string FirstName { get; set; }

public string LastName { get; set; }

ValidateField(MinLength = 0, MaxLength = 2)
public string MiddleName { get; set; }

ValidateField(IsRequired = true, IsEmail = true)
public string Email { get; set; }

ValidateField(LessThan = 60, GreaterThan = 8)
public int Age { get; set; }
}

WPF Side

For Adornering the Control

Utilities:AttachedProperties.ValidateEntity="{Binding ElementName=window, Path=DataContext.Person}"
Utilities:AttachedProperties.ValidateFieldName="First Name"

Note : On satisfying the validation adoner disappears and re-appears on validation fail

EntityValidation.JPG

EntityValidation1.JPG

EntityValidation2.JPG

EntityValidation3.JPG

About the Author

Amarnath Kashyap
Amar1_160x120_scaled_cropp.jpg
I am a software professional always with anticipation to contribute significantly to the IT community. Has a great interest in working with latest technologies in order to get better results in business / applications. Currently having 8 years of extensive experience in developing enterprise applications with Microsoft technologies like C#, WPF, Entity Framework, SliverLight, WinRT, Windows Phone, WCF, ASP.Net, SQL Server under MVC, MVP and MVVM patterns and has interpersonal skills with exposure to all aspects of the software development life cycle.

Last edited May 21, 2013 at 4:55 PM by amarnathkashyap, version 18