问题
How can I check if there are only strings in request.resource.data.myArray
?
Loops and recursive calls are not allowed.
回答1:
This is not possible today, unless you know the size of the array, and you write an expression to check the element at each index. However, what you're asking is a reasonable thing to want to do, and you should file a feature request for it. Bear in mind, though, that it's a long way off from happening.
The only way this would eventually work is if the rules language had a lambda type where you could pass a predicate function into a method that ensures it only returns true for every element in the list. But that concept doesn't exist right now, so it would require a fair amount of effort to implement.
来源:https://stackoverflow.com/questions/55071893/firestore-rule-only-strings-in-list