title: Is there an alternative to writeFields?
body: <p><a href="https://medium.com/day4/firebases-firestore-rules-what-the-f-part-2-fed76a9db25#428c" rel="nofollow noreferrer">This article</a> stated that "[writeFields] is now deprecated".<br>
  Additionally, I cannot find any documentation for <code>writeFields</code>, it is not even listed as part of <a href="https://firebase.google.com/docs/reference/rules/rules.firestore.Request" rel="nofollow noreferrer"><code>Request</code></a> in the documentation anymore.</p>
  
  <h2>Problem</h2>
  
  <p>The problem I am facing with Cloud Firestore Security Rules is that verifying that only particular fields are modified requires massive amounts of conditions.<br>
  For example, if I want to verify that the only modified value of a document is <code>cakes</code>, I have to write the following rule:</p>
  
  <pre class="lang-js prettyprint-override"><code>allow update: if request.resource.data.size() == 20
                &amp;&amp; request.resource.data.likes == resource.data.likes
                &amp;&amp; request.resource.data.name == resource.data.name
                &amp;&amp; request.resource.data.date == resource.data.date
                &amp;&amp; request.resource.data.body == resource.data.body
                &amp;&amp; request.resource.data.title == resource.data.title
                &amp;&amp; request.resource.data.tags == resource.data.tags
                &amp;&amp; request.resource.data.comments == resource.data.comments
                &amp;&amp; request.resource.data.answers == resource.data.answers
                &amp;&amp; request.resource.data.awards == resource.data.awards
                &amp;&amp; request.resource.data.image == resource.data.image
                &amp;&amp; request.resource.data.link == resource.data.link
                &amp;&amp; request.resource.data.format == resource.data.format
                &amp;&amp; request.resource.data.type == resource.data.type
                &amp;&amp; request.resource.data.user == resource.data.user
                &amp;&amp; request.resource.data.views == resource.data.views
                &amp;&amp; request.resource.data.reports == resource.data.reports
                &amp;&amp; request.resource.data.roles == resource.data.roles
                &amp;&amp; request.resource.data.category == resource.data.category
                &amp;&amp; request.resource.data.votes == resource.data.votes
                &amp;&amp; request.resource.data.cakes is int;
  </code></pre>
  
  <p>Using <code>writeFields</code>, the <strong>exact same</strong> rule would have looked like this:</p>
  
  <pre class="lang-dart prettyprint-override"><code>allow update: if request.writeFields.hasOnly(['cakes']) &amp;&amp; request.resource.data.cakes is int;
  </code></pre>
  
  <p>What can I do to decrease the code size of my rules / what is the alternative to <code>writeFields</code>?</p>
  
  <h2>Limits</h2>
  
  <p>There are two <a href="https://firebase.google.com/docs/rules/rules-behavior#security_rule_limits" rel="nofollow noreferrer">limits</a> mentioned in the documentation that make this problem even worse:</p>
  
  <ul>
  <li><p>Maximum number of expressions evaluated per request:     1,000</p></li>
  <li><p>Maximum size of a ruleset:   64 KB</p></li>
  </ul>
  
  <p>I expect to reach both of these at some point with this limitation.</p>