title: knockout validating multiple levels deep observable array
body: <p>Hi I need to create a custom validator that will be aplyed for each element of an observable array using knockout validation plugin. The structure of my object will look something like this when I post it to the server:</p>
  
  <pre><code>var viewModel = {
     evaluationFormDataContract: {
         studentAssignmentInstanceId: value,
         evaluationType: value,
         categories: array[
         CategoriesOnEvaluationDataContract1 = {
             memo: value,
             categoryId: value,
             title: value,
             // Fields needed for validation
             hasMemo: value,
             memoIsMandatory: value
             questions: array[
             QuestionsOnEvalCategoryDataContract1 = {
                 memo: value,
                 grade: value,
                 hasGrade: value,
                 hasMemo: value,
                 showOnlyMemo: value
             },
             QuestionsOnEvalCategoryDataContract2 = {
                 memo: value,
                 grade: value,
                 hasGrade: value,
                 hasMemo: value,
                 showOnlyMemo: value
             }]
         },
         CategoriesOnEvaluationDataContract2 = {
             memo: value,
             categoryId: value,
             title: value,
             // Fields needed for validation
             hasMemo: value,
             memoIsMandatory: value
             questions: array[
             QuestionsOnEvalCategoryDataContract1 = {
                 memo: value,
                 grade: value,
                 hasGrade: value,
                 hasMemo: value,
                 showOnlyMemo: value
             },
             QuestionsOnEvalCategoryDataContract2 = {
                 memo: value,
                 grade: value,
                 hasGrade: value,
                 hasMemo: value,
                 showOnlyMemo: value
             },
             QuestionsOnEvalCategoryDataContract3 = {
                 memo: value,
                 grade: value,
                 hasGrade: value,
                 hasMemo: value,
                 showOnlyMemo: value
             }]
         }, ]
     }
  </code></pre>
  
  <p>}</p>
  
  <p>Now the validation will have to be applyed only on the two nested arrays and will be done based on some properties.</p>
  
  <p>The first validation has to be done on each object of the categories array and it will check if hasMemo and memoIsMandatory if this is the case memo will be required.</p>
  
  <p>The second validation will be done on each object of questions array and it will check if hasGrade if that is the case grade will be required.</p>
  
  <p>The last validation will be done on hasMemo and showOnlyMemo and are will be used for the memo value on the questions object.</p>
  
  <p>Reading the documentation for the validation plugin I found how I would extend a simple observable .Witch it seems to be done something like this:</p>
  
  <pre><code>ko.validation.rules['mustEqual'] = {
      validator: function (val, otherVal) {
          return val === otherVal;
      },
      message: 'The field must equal {0}'
  };
  </code></pre>
  
  <p>But I do not think this will work for the structure of my viwmodel.How can I create  validators for each observable in my observableArrays?</p>