0

I'm trying to write a rule for my iOS app which is using firebase to have a unique user name .I've been stuck for two days and any help would be appriciated This the firebase db rule that I'm trying to execute

{
  "rules": {
    ".read": "auth != null",
    ".write": "auth != null",
      "Users":{
        "$uid":{
          "userName":{
            ".validate": "!root.child('userName').child(newData.val()).exists()"

          }
        }
      }
  }
}
Sruthin Gaddam
  • 159
  • 2
  • 14
  • See http://stackoverflow.com/questions/25294478/how-do-you-prevent-duplicate-user-properties-in-firebase – Frank van Puffelen Aug 06 '16 at 15:46
  • Thank you for your response , I did see it that solution never worked for me . It is not even saving data when i try it so i wanted to what i was doing wrong or if there was another way . Thanks for your reply – Sruthin Gaddam Aug 06 '16 at 16:28
  • The only way to ensure uniqueness is by keeping an index of the user names. The rules you show don't have an index of user names, which is the crux of the answer I linked. – Frank van Puffelen Aug 06 '16 at 22:29

0 Answers0