title: Backbone: validating attributes one by one
body: <p>I need to validate a form with a bunch of inputs in it. And, if an input is invalid, indicate visually in the form that a particular attribute is invalid. For this I need to validate each form element <strong>individually</strong>.</p>
  
  <p>I have one model &amp; one view representing the entire form. Now when I update an attribute:</p>
  
  <pre><code>this.model.set('name', this.$name.val())
  </code></pre>
  
  <p>the validate method on the model will be called.</p>
  
  <p>But, in that method I am validating <strong>all</strong> the attributes, so when setting the attribute above, all others are also validated, and if any one is invalid, an error is returned. This means that even if my 'name' attribute is valid, I get errors for others.</p>
  
  <p>So, how do I validate just one attribute?</p>
  
  <p>I think that it is not possible to just validate one attribute via the validate() method. One solution is to not use the validate method, and instead validate every attribute on 'change' event. But then this would make a lot of change handlers. Is it the correct approach? What else can I do?</p>
  
  <p>I also think that this points to a bigger issue in backbone:</p>
  
  <blockquote>
    <p>Whenever you use <code>model.set()</code> to set an attribute on the model, your validation method is run and <strong>all</strong> attributes are validated. This seems counterintuitive as you just want that single attribute to be validated.</p>
  </blockquote>