This project is read-only.

ASP.NET MVC V2 has built in DataAnnotation Validation

Jul 31, 2009 at 4:36 PM

I was just reading Scott Guthrie's post on ASP.NET MVC V2 Preview 1 and I saw that it includes DataAnnotation Validation Support. He goes on to say that a future preview will include both server and client side validation by using the jQuery.Validation plugin.

I'm wondering how this will effect xVal ... what do you think?

Aug 3, 2009 at 6:39 PM

I haven't used the preview yet, but it sounds identical to xVal.  So I guess it will no longer be needed for once you upgrade to version 2. 

Aug 4, 2009 at 9:01 AM

I hope that ASP.NET MVC v2's client-side validation supports all the features that you want. Bear in mind that Microsoft hasn't yet confirmed which of the following features will be supported:

  • Support for custom or alternative server-side validation frameworks (e.g., NHibernate Validation, Castle Validator, or your custom markup)
  • Infrastructure for running server-side validation within the model layer at arbitrary times, bubbling its output up to the UI 
  • Custom client-side validation logic
  • Localisation of client-side error messages
  • Support for custom or alternative client-side validation frameworks (e.g., ASP.NET native validation) - though I don't think many people are using this one

Your best option today is probably to use the DataAnnotations rules with xVal and ASP.NET MVC v1. Then, when ASP.NET MVC v2 is released, if it has the features you want, you may not need xVal and may be able to switch to ASP.NET MVC v2's built-in client-side validation feature and retain your existing DataAnnotations rules.

Aug 19, 2009 at 6:42 PM
Edited Aug 19, 2009 at 6:46 PM

ScottGu just confirmed:

Next ASP.NET MVC 2 Preview will include jQuery validation integration that provides automatic client/server validation support.

The metadata model for the HTML helpers and jquery integration will be pluggable and extensible.

This means you can use the built-in dataannotation validation support or use an alternative model validation approach if you prefer.

Will be easy to use dataannotations, castle validate, entlib, fluent on total custom and have sweet client and server validation support

Phil Haack also chimes in:

In other words, plug-in your own metadata providers as well as your own client and server validation systems. Full extensibility.

Aug 19, 2009 at 8:26 PM

This reminds me a lot of NDoc/Sandcastle and NUnit/MSTest ...