With Firestore Security Rules (version 2), how can I turn a Path object into a String? The entire path as one String, not the individual segments.
I'm trying to write a generic function to use in various Match statements. Something like this:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// "pathobj" is a rules.firestore.Path object
function getPathAsString(pathobj) {
// Does not work:
return pathobj.toString();
}
// I would expect the following to evaluate to True:
match /foo/{fooid} {
allow read: if getPathAsString(path('one')) == 'one'
&& getPathAsString(path('one/!two')) == 'one/!two';
}
}
}
Does anyone know if this is possible? I read the documentation on Path and have tried various things in the Firestore Rules Simulator, all with no success.