Reputation: 1627
I am using firebase for my project
now I wan to customize my Rule
the Default rules is :
{
"rules": {
".read": "auth != null",
".write": "auth != null"
}
}
which Allow to read and write all data for Authorized users
now I want to Allow read and write all data for Authorized users
and I want to add this too
{
"rules": {
"visits": {
"$visit_id": {
"mister_id": {
".write": "data.val() == ''"
}
}
}
}
}
Now how Can I add this two Rules
Upvotes: 1
Views: 77
Reputation: 2048
I think you need something like that :
{
"rules": {
".read": "auth != null",
".write": "auth != null",
"visits": {
"$visit_id": {
"mister_id": {
".validate": "(data.val() == null) || (data.isString() && (data.val().length == 0))"
}
}
}
}
}
You can find all what you need with the Firebase Datase Rules documentation.
Upvotes: 3
Reputation: 3654
Haven't try yet but it may be another solution:
{
"rules": {
".read": "auth != null",
".write": "auth != null",
".validate": "newData.hasChildren(['visit_id', 'mister_id'])"
}
}
Upvotes: 2