Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top