title: How to detect if field exists in a Firestore document in security rules
body: <p>I have these Firestore Security Rules. I need to check if the 3 amounts "redAmount", "greenAmount" and "blackAmount" added together exceed the user's balance. If so, the update should be rejected.</p>
  
  <pre class="lang-js prettyprint-override"><code>function checkSums() {
      return futureDocument().redAmount +  futureDocument().blackAmount + 
      futureDocument().blackAmount &lt;= getUserDoc().amount;
  }
  </code></pre>
  
  <p>But this functions fails if one of the amounts is undefined => not set, which I want to be 0, but I can't. Any ideas on how to fix this?</p>
  
  <p>This problem is not solved by referencing to the "How  to validate that a field is undefined" question.</p>