Is there any way to validate newData using Firebase security rules as follows?
"Event": {
 "$eventId": {
  "Outcome": {
   ".validate": "
     newData.parent().parent().parent().child('Users/'+$userId+'/Events/'+$eventId+'/Opinion').exists()
   "
What I'd like to achieve is to make sure that a multi-location update happens atomically.
Use-case: How to make sure that a single write contains the outcome for the event and an opinion for each user
At the moment, '$userId' cannot be added to the rule, so the above rule is invalid. I want to have something like '*' instead of '$userId' to make sure that the 'Outcome' of the 'Event' can be updated, only if ALL the 'opinion' fields under all 'Users' also get updated. Is this possible?
UPDATE: more details: the rule for updating the user's data looks like this:
"Users": {
     "$userId": {
      "Events": {
       "$eventId": {
        ".validate": "
          newData.parent().parent().parent().parent().child('Event/'+$eventId+'/Outcome').exists()
        "
}}}}
This works fine, because the only wildcard needed is the $eventId which is already defined before the ".validate". However, under the "Event", there is no "$userId", so the "$userId" wildcard cannot be used there.
This is how I do my multi-location update:
var multiData = {}
multiData['Event/' + $scope.eventId + '/Outcome'] = $scope.eventOutcome;
for (var u=0; u<$scope.allUsers.length; u++) {
      var curUser = allUsers[u];
      multiData['Users/' + curUser.id + '/Events' + $scope.eventId + '/Opinion'] = $scope.usrOpinions[u];
}
ref.update(multiData, function(error) {
      if(error) {...}
      else {...}
});
