xVal is a validation framework for ASP.NET MVC applications. It makes it easy to link up your choice of server-side validation mechanism with your choice of client-side validation library, neatly fitting both into ASP.NET MVC architecture and conventions.
Project Description
xVal is a validation framework for ASP.NET MVC applications. It makes it easy to link up your choice of server-side validation mechanism with your choice of client-side validation library, neatly fitting both into ASP.NET MVC architecture and conventions.
Features
Define your validation rules using attributes on model properties, e.g., [Required] [StringLength(50)] public string Name { get; set; } (Or, if you prefer, you can supply rules programmatically or you can just hard-code them in specific views)
- Designed to fit into ASP.NET MVC conventions for handling form posts and storing and retrieving error information in ModelState
- Use your choice of server-side validation framework. Out of the box, xVal lets you use .NET 3.5's built-in DataAnnotations classes or Castle Validator (or both). If you want to use something different, you can create your own provider just by implementing IRulesProvider.
- Use your choice of client-side validation library. Out of the box, xVal lets you use jQuery Validation or ASP.NET's native client-side validation library (a.k.a. WebUIValidation.js, as used by WebForms). Or, use any other client-side validation library by writing a plug-in to configure it using xVal's standard JSON rules description format.
- Supports localized error messages using resource files. Vary the language of your validation messages according to the current thread's culture.
- Add custom validation logic that runs both on the server and on the client, either by subclassing an existing rule or by referencing a custom JavaScript function
How to use xVal
For more information, and to see a quick tutorial, see this blog post. Further enhancements are planned To Do.