title: mvc3 validation when using buddy classes
body: <p>I am working on an mvc3 application and having some problems with getting validation to work as I want.</p>
  
  <p>The application is using buddy classes for the models. (This is something I haven't used in the past and I am a little confused why they are used...anyway)</p>
  
  <p>I want to add required fields to ensure data been submitted is correct. I have tried adding the required field to the buddy class.</p>
  
  <p>When I submit the form no client-side validation takes place and the debugger steps into the entity frameworks generated code. Here is complains that the fields that contain null values are causing are invalid. If I step through all of those it finally gets to the controller where my  if (ModelState.IsValid) is showing false.</p>
  
  <p>I have client-side validation switched on.</p>
  
  <p>Am I meant to be applying the data validation at the buddy class level or at the view model?</p>
  
  <p>One other question is why use buddy classes? to me they seem to over complicate things.</p>
  
  <p>Updated added an example of the buddy class</p>
  
  <pre><code>[MetadataType(typeof (CustomerMetaData))]
  public partial class Customer
  {
      public string Priorty
      {
          get
          {
              var desc = (Priority) Priority;
              return desc.ToString().Replace('_', ' ');
          }
      }
  
  internal class CustomerMetaData
  {
      [Required]
      [DisplayName("Priorty")]
      public string Priorty { get; set; }
  </code></pre>