In my firestore security rules, I want to have a rule, that checks if all elements of a list are of type string.
My "user" documents have a field called "friends". It is an list of strings, that represent the documentIDs of other user documents. These are my current rules:
function userIsAuthenticated() {
return request.auth != null;
}
match /users/{userID} {
function resourceIsValidUser() {
return displayNameIsValid();
}
function displayNameIsValid() {
return request.resource.data.displayName is string &&
request.resource.data.displayName.size() > 0 &&
request.resource.data.displayName.size() < 17;
}
function photoUrlIsValid() {
return request.resource.data.photoUrl is string;
}
function friendsIsValid() {
return request.resource.data.friends is list;
}
function userIsUserOwner() {
return request.auth.uid == userID;
}
allow read: if userIsAuthenticated();
allow write: if
userIsAuthenticated() &&
resourceIsValidUser() &&
userIsUserOwner();
}
Is there anything I could add to the friendsIsValid() function to ensure the friends-list only contains string-values?