title: Firebase prevent duplicate categories using rule
body: <p>Here is my database structure for <strong>categories</strong></p>
  
  <p><a href="https://i.stack.imgur.com/hEH81.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hEH81.png" alt="enter image description here"></a> </p>
  
  <p>I want prevent duplicate data using <strong>Firebase rules</strong></p>
  
  <p>here is my firebase rule</p>
  
  <pre><code> {
      "rules": {
      ".read": "auth != null",
      ".write": "auth != null",
  
  
      "categories": {
        "$catid": {
  
         ".validate": "!root.child(newData.child('type').val()).exists()"
        }
      }
  } 
  }
  </code></pre>
  
  <p>When I am trying to insert again <strong>java</strong> it's inserting duplicate of <strong>java</strong></p>
  
  <p>how do I prevent to insert duplicate category</p>