How can I validate all keys in map in Firestore rules? Each key in map is an identifier related to a document.
Example:
User creates an invitation document with other documents access like this:
{
"email": "[email protected]",
"documents": {
"document1": true,
"document2": true,
...
}
}
How can I check document1 exists in database (ie. in documents collection)?
You can't write loops in security rules, so if you have an unknown number of documents to work with, you won't be able to validate them. Instead, consider using Cloud Functions to check the values after it's been added, and delete the invitation if it's not valid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With