Validate your models anywhere in your application
There are many places in your applications that you wish you could use the System.ComponentModel.DataAnnotations attributes and then automatically validate your objects with a single call. Now you can!
Here is how you can use the validator
var application = new Application() { Applicant = new Person { Email = "[email protected]", FirstName = "John Connor Wright Teddington", LastName = null }, Address = new Address { StreetName = "123 CodeVille Terrace", City = "See Sharp" }, PaymentDetails = new Payment { CreditCardNumber = "4111111111111110" } }; if (DataAnnotationsValidator.Validate(application)) { // Do something awesome! } else { // Let your user know that something awful happened. }
Benefits of the Data Annotations Validator
- Validation in all your .NET application including MVC
- Validate objects in your business layer to ensure that the requirements are met
- Ease application maintenance and create predicatable results
- Future proof quality checking in your application allowing for newer attributes to automatically take effect
- Ensures that your application is being built correctly (guiding light)
- Stop the problems before they start, always ensuring that the your data is valid.
What do you get when you buy?
- A fully documented assembly with XML comments and debug files (PDB)
- Console application Demo Project
- A comprehensive help file documenting full usage
Here are the remaining class to support the demo above
public class Application { [Required] public Person Applicant { get; set; } [Required] public Address Address { get; set; } public Payment PaymentDetails { get; set; } } public class Person { [EmailAddress] [Required] public string Email { get; set; } [StringLength(15)] public string FirstName { get; set; } [StringLength(15)] public string LastName { get; set; } } public class Address { [Required] public string StreetName { get; set; } public string Locality { get; set; } public string City { get; set; } public string County { get; set; } [Required] public string PostCode { get; set; } [Required] public string Country { get; set; } } public class Payment { [CreditCard] public string CreditCardNumber { get; set; } }