title: Firebase rules: Chat blocks
body: <p>I have the following firebase rules for my chat:</p>
  
  <pre><code>"chat_messages": {
          ".read": true,
              ".write": false,
            "$key": {
              ".read": true,
                      ".write": "!root.child('chat_blocks/'+newData.child('username').val()).exists()",
              ".validate": "newData.child('content').val().length &gt;= 2"
            }
        },
  </code></pre>
  
  <p>if the username is listed in the chat_blocks node, write is set to <strong>false</strong>.</p>
  
  <p>The problem is that it's impossible to delete messages when using the above rules.</p>
  
  <p>Changing <code>.write</code> of chat_messages to <code>true</code> allows everyone to post, even if they are listed in the chat_blocks node.</p>
  
  <p>Any ideas what's wrong?</p>
  
  <p><a href="https://i.stack.imgur.com/NpQ6i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NpQ6i.png" alt="enter image description here"></a></p>