title: JSON Schema - multiple types
body: <p>I have this schema. It checks comments, and works fine at the moment.</p>
  
  <pre><code>var schema = {
    id: '',
    type: 'object',
    additionalProperties: false,
    properties: {
      text: {
        type: 'string',
        minLength: 1,
        required: true
      },
      author: {
        type: 'number',
        required: true
      }
    }
  }; 
  </code></pre>
  
  <p>My comment structure is:</p>
  
  <pre><code>{
    text: "Hello world!",
    author: 1
  }
  </code></pre>
  
  <p>But now, I need to validate an array of objects like this. So I can get something like:</p>
  
  <pre><code>  [
      {
        text: "Hello world! Im comment #1",
        author: 1
      },
      {
        text: "Super awesome comment #2!",
        author: 0
      }
    ]
  </code></pre>
  
  <p>Sometimes I get one comment only so I get one object, and need to use first schema, but sometimes I get an array of comments, and my schema does not fit.</p>
  
  <p>I heard about json schema <strong><code>anyOf</code></strong>, but I dont know how to do it.</p>
  
  <p>Some like:</p>
  
  <pre><code>anyOf  
     schema-1 (object)
     schema-2 (array with objects)
  </code></pre>
  
  <p>Any help?</p>
  
  <p>Thanks.</p>