title: An ASP.NET MVC validator to make sure at least one checkbox is checked
body: <p>I have an ASP.NET MVC 2 project in which I've created a data transfer object to receive data from a web page form. The form has two groups of checkboxes on it. I want to validate the object to make sure that at least one of the checkboxes in each group is checked.</p>
  
  <p>I'm doing the validation on the server side so that a user won't be able to hack around any client-side validation. (I will add client-side validation with jQuery later; that's easy.)</p>
  
  <p>My understanding is that I have to create my own custom ValidationAttribute for my data transfer object class, but I don't understand how to create and use one that can accept an arbitrary list of checkbox properties to make sure that at least one of them is true. I am guessing I will have to call the attributes like this:</p>
  
  <pre><code>[AtLeastOneCheckbox("set1check1", "set1check2", "set1check3",
      ErrorMessage = "You must check at least one checkbox in set 1.")]
  [AtLeastOneCheckbox("set2check1", "set2check2", "set2check3", "set2check4", "set2check5",
      ErrorMessage = "You must check at least one checkbox in set 2.")]
  public class MyFormDTO
  {
      ...
  }
  </code></pre>
  
  <p>What would the implementation of AtLeastOneCheckboxAttribute look like?</p>
  
  <p>Or is there a different way that I should do this kind of validation?</p>