views:

853

answers:

3

With the preview 2 release of ASP.NET MVC 2, we now have base classes to implement our own custom providers for metadata and validation. Specifically, with ModelMetadataProvider and ModelValidatorProvider.

There isn't a lot of documentation on these yet (just released yesterday as a preview, so I'm neither surprised nor disappointed).

Has anyone gotten custom implementations of either of these working? A very simple example (metadata and validator for just "Required") would be great!

Perhaps a lot of people have the same idea, but I'd like to use IronRuby to inject the metadata, and I'm looking for any example to get started.

Thanks!

Edit: Sounds like Brad Wilson (of xUnit.net fame) has some blog posts coming for this exact thing! If he doesn't answer here, I'll create an answer with links when those posts are ready.

Edit2: Sankarsan Bose over at CodingNDesign also has posts on the subject. (ModelValidator at the moment). Including here for future reference.

+2  A: 

Here's an example validator provider, using Enterprise Library:

http://bradwilson.typepad.com/blog/2009/10/enterprise-library-validation-example-for-aspnet-mvc-2.html

The metadata sample is coming soon.

Brad Wilson
A: 

In your blog you mention: We’ve added a pluggable metadata provider system in ASP.NET MVC 2. Are there examples of this [yet] (ex: constructing one from a config or xml file, AND plugging it in), Or docs on how to do this? Thanks, -Jeff

jeff
A: 

This article by Daniel Chambers seems to be a good read if you are interested in asp.net mvc model metadata and model validation topics.

http://www.digitallycreated.net/Blog/54/deep-inside-asp.net-mvc-2-model-metadata-and-validation

Regards,
Sendhil

Sendhil

related questions