Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9162407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:12:20+00:00 2026-06-17T14:12:20+00:00

I have a type Content (from a custom CMS) that must not be validated

  • 0

I have a type “Content” (from a custom CMS) that must not be validated by the DataAnnotationsModelValidatorProvider. I don’t want to remove the DataAnnotationsModelValidatorProvider from the providers since I need it for all other types.

I thought of creating a custom ModelValidatorProvider which inherited from DataAnnotationsModelValidatorProvider and in the only public entry point (the method GetValidators) check if the containerType is of type “Content” then return an empty collection of validators and let another custom ModelValidatorProvider handle the validation for this specific type. But my friends at Microsoft decided to sealed this method in the AssociatedValidatorProvider which is the base class of DataAnnotationsModelValidatorProvider.

Do you see any other way of skipping the DataAnnotationsModelValidatorProvider for a specific type?

If not, could you vote for my suggestion over here: http://aspnet.uservoice.com/forums/41201-asp-net-mvc/suggestions/3571625-remove-sealed-on-method-getvalidators-of-type-asso

This is a discussion from someone else facing a similar problem: http://forums.asp.net/t/1751517.aspx/1

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T14:12:21+00:00Added an answer on June 17, 2026 at 2:12 pm

    Couldn’t you just inherit directly from ModelValidatorProvider? You could then modify GetValidators as you wish. For example:

    public class CustomValidatorProvider : ModelValidatorProvider
    {
        private readonly DataAnnotationsModelValidatorProvider _provider = new DataAnnotationsModelValidatorProvider();
    
        public override IEnumerable<ModelValidator> GetValidators(ModelMetadata metadata, ControllerContext context)
        {
            if (metadata.ModelType == typeof(Content) || metadata.ContainerType == typeof(Content))
            {
                return Enumerable.Empty<ModelValidator>();
            }
    
            return _provider.GetValidators(metadata, context);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an archetype content type that previously was not folderish. Now I have
I have module that implements custom content type via NodeAPI hooks ( hook_insert ,
I want to build a custom content type that will be the basis of
I have a custom content type create in visual studio 2010: custom http://img204.imageshack.us/img204/439/customf.jpg Here
I have a site content type that was used for a handful of lists
I have several different content type nodes (videos, image galleries, stories...) that I would
I am attempting to import data into Orchard CMS. I have a custom type,
I have the following being echoed from a custom wordpress post type by get-client-logos.php
I have a custom content type which has a field called location which is
I am using Drupal 7 and have created a custom content type and a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.