rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /visitors/{visitor} {
      allow create: if exists(/databases/$(database)/documents/invited/$(request.resource.data.invitationId))
      	&& !exists(/databases/$(database)/documents/submitted/$(request.resource.data.invitationId));
    }
    match /submitted/{submitted} {
      allow create: if exists(/databases/$(database)/documents/invited/$(request.resource.id))
    }
  }
}