title: Set tag attribute based on variable value with kendo binding
body: <ol>
  <li>I create a variable list of input elements which are bound to a kendo MVVM.</li>
  <li>I have a kendo validation running over all my input elements (this is standard functionality), checking if the input is empty.</li>
  <li><p>The objects in my MVVM have an attribute IsMandatory, like this:</p>
  
  <p><code>{ Name: "test", ID: 12, ... , IsMandatory: false }</code></p></li>
  <li><p>The validation must not try to validate elements with an IsMandatory value of false. How can I achieve this?</p></li>
  </ol>
  
  <p>I know I can bind attributes to MVVM values like this:</p>
  
  <pre><code>&lt;input data-bind="attr: { name: Name }" /&gt;
  </code></pre>
  
  <p>Which results in an actual output like this for the object above:</p>
  
  <pre><code>&lt;input name="test" /&gt;
  </code></pre>
  
  <p>However, the <code>required</code> attribute used for the standard required validation is value-less, like this.</p>
  
  <pre><code>&lt;input name="test" required /&gt;
  </code></pre>
  
  <p>So basically I need to create elements with a required attribute if the IsMandatory attribute in my MVVM object is set to true, and without the required attribute if it is set to false.</p>
  
  <pre><code>{ Name: "test1", ID: 1, ... , IsMandatory: true }
  { Name: "test2", ID: 2, ... , IsMandatory: false }
  { Name: "test3", ID: 3, ... , IsMandatory: true }
  
  &lt;input name="test1" required /&gt;
  &lt;input name="test2" /&gt;
  &lt;input name="test3" required /&gt;
  </code></pre>
  
  <p>Is there an elegant solution to this problem? Other than putting an if-else around the creation of each element. Or is there a different solution of excluding/including elements in my validation?</p>
  
  <p>One option I could imagine would be to create a custom required validation, checking if the IsMandatory attribute for the input is set to true and only then validate the element. However, I could not find any possibility to get my hands on the MVVM object of the current element.</p>
  
  <pre><code>...
  validation: {
      required: function (input) {
          var observable = // Get the kendo observable from input here !!!!!
          if (observable.IsMandatory) {
              return input.val() != "";
          }
          return true;
      }
  },
  ...
  </code></pre>