I am using the following rule to check that only 'admins' can write to the traps section.
"traps": {
".read": "auth != null",
".write": "auth != null && root.child('admins').child(auth.uid).val() === true",
},
This works fine. However if I change the rule to the following,
"traps": {
"$trap" : {
".read": "auth != null",
".write": "auth != null && root.child('admins').child(auth.uid).val() === true",
}
},
then I get a permission error. W/SyncTree: Listen at /traps failed: DatabaseError: Permission denied.
The reason I'm making this structure change is I'm trying to use the validate function but as I can't get past this first issue, I can't get as far as the validate.
"traps": {
"$trap" : {
".read": "auth != null",
".write": "auth != null && root.child('admins').child(auth.uid).val() === true",
"trapNumber": {
".validate": "newData.isString()"
}
}
},
I'm sure this is a rookie comprehension error but I've made little progress with this after trying many permutations. You assistance would be greatly appreciated.
Update 20160629
Frank, the admin section looks as follows
admins
somegeneratedkey: true
root.child('admin')requirement, and the actual code for the write operation that fails. - Frank van Puffelen