title: Multi-value enum in JSON schema?
body: <p>I have an array that contains strings, such as:</p>
  
  <pre><code>[ 'foo', 'bar' ]
  </code></pre>
  
  <p>The possible values are limited. For example, valid values are <code>foo</code>, <code>bar</code>, and <code>baz</code>.</p>
  
  <p>Now the array shall be valid when it contains only values that are valid, no value more than once, but it can have an arbitrary number of values.</p>
  
  <p>Examples for valid arrays would be <code>[ 'foo' ]</code>, <code>[ 'foo', 'bar' ]</code>, and <code>[ 'bar', 'baz' ]</code>. Examples for invalid arrays would be <code>[]</code>, <code>[ 'foo', 'foo' ]</code>, and <code>[ 'bar', 'something-else' ]</code>.</p>
  
  <p>How can I do this validation using JSON schema? So far, I have figured out the <code>array</code> type which provides the <code>minItems</code> and the <code>uniqueItems</code> properties. What I could not yet figure out is: <strong>How to allow multiple (but only valid) values?</strong> I know that there is <code>enum</code>, but this only allows a single value, not multiple ones.</p>
  
  <p>Can anybody help?</p>
  
  <p>PS: Just in case it matters, I'm using the <a href="https://github.com/epoberezkin/ajv/" rel="noreferrer">ajv</a> module with Node.js to run the validation.</p>