I am coming from this question. I thought about starting a bounty on it because it has not received any attention in months and over the time I did not see any answers, but I think that my desire is a bit different.
If there is a number as a field of a document, but specified as a string
:
A problem with Firestore Rules arises.
Checks like this become impossible:
resource.data.number > 11
It is not possible to compare strings as if they were ints.
The simulator exception is as follows:
Unsupported operation error. Received: string > int. Expected: constraint > constraint, int > int, float > float, duration > duration, timestamp > timestamp, constraint > any, any > constraint.
Is there a way to convert my operation to int > int
?
Check out this link that shows you how to convert strings to integers in the Firestore rules docs.
So your check could be: