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 7770893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:31:06+00:00 2026-06-01T16:31:06+00:00

Here is a description (ASP.NET MVC 3): I have this parameter DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes in the

  • 0

Here is a description (ASP.NET MVC 3):

  1. I have this parameter DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes in the default value true (checked with the debugger)

  2. I have value-type field in my model (int, DateTime, decimal):

    public class MyModel
    {    
       public int SomeField { get; set; }
    }
    
  3. When I post empty form to this action (no SomeField specified):

      public ActionResult Submit(MyModel request)
      { 
          if (ModelState.IsValid)
          {
              ..
          }
      else
          {
              ..
          }
       }
    
  4. I don’t have any validation errors! It seems to me logical — the default value of int is 0. Which is a value.

Questions:

If I want to force this value always expicitly set in request I should make it nullable and put [Required] on it, this works. But what DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes is for?

  • 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-01T16:31:08+00:00Added an answer on June 1, 2026 at 4:31 pm

    If we refer to ASP.NET MVC sources, DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes is checked only in DataAnnotationsModelValidatorProvider.Getvalidators method which provides validation metadata for HTML Helpers (when rendering data-val-* attributes) and DefaultModelBinder.

    So, DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes could be set when there is need to change behaviour of client-side validation and allow passing empty values(i.e. field is posted but has no value set) for value types to controller action.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started to learn ASP.NET MVC 3 form this book and I
I have read some here: http://www.asp.net/mvc/tutorials/mvc-music-store-part-4 and set some stuck namespace MvcMusicStore.Models { public
I'm writing my first asp.net mvc application and I have a question about custom
I'm trying to do the tutorial here: http://www.asp.net/entity-framework/tutorials/handling-concurrency-with-the-entity-framework-in-an-asp-net-mvc-application In the ActionResult Edit, I have
I'm new to asp.net mvc, but I've thoroughly searched on this topic everywhere. I've
I'm trying to get an ASP.NET MVC app working... I should have known it
I am working on asp.net mvc application using the mvc2 framework. Here is the
I'm using ASP.NET MVC 3 code-first and I have added validation data annotations to
I have been working in ASP.NET Web Applications (not MVC) for a while at
I have a new ASP.NET MVC project (my first), and I had been running

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.