Firebase realtime database validate child object in array

Viewed 75

Trying to validate that an array value only contains certain elements.

The "focus" key, should only contain any or both of the following: "movement", "strength".

So I tried sending this:

{
  "focus": ["movement"]
}

... and the security rules:

 "$id": {
    "focus" : {
        ".validate": "newData.hasChild('movement') || newData.hasChild('strength') || newData.hasChildren(['strength', 'movement'])"
    }
}

But get "Simulated update denied" and cannot understand why.

Thanks in advance

0 Answers
Related