title: Firestore Rules - Validate if data exists in other collection
body: <p>I'm currently working on my firestore rules and I need to validate the incoming data. Besides what I already have, I also need to validate if the incoming origin and tag fields exist in the collection origins and tags. I've found how to do so when using references but I'm using embedded data so I'm unsure how to exactly do it.</p>
  
  <pre><code>function incomingData() {
    return request.resource.data
  }
  function validTicket() {
      return incomingData().email is string &amp;&amp;
      incomingData().description is string &amp;&amp;
      incomingData().address is string &amp;&amp;
      incomingData().location is string &amp;&amp;
      incomingData().postCode.matches('^[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9]') &amp;&amp;
      incomingData().size() == 5 &amp;&amp;
      incomingData().hasAll(['email','description', 'address', 'location', 'postCode']) &amp;&amp;
      isSecretary()
  }
  </code></pre>
  
  <p>In the tags collection, every document has a single value with the tag name. The same applies to the origins.</p>
  
  <p><a href="https://i.stack.imgur.com/s3xgB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s3xgB.png" alt="enter image description here"></a></p>