I have following character collection structure in my database (firestore)
/characters/{uid}
 - username: string
 - clan: string
 - mana: number
 - health: number
 etc...
I am trying to figure out a security rule for /characters/{uid} with following logic
service cloud.firestore {
  match /databases/{database}/documents {
    // Characters
    match /characters/{characterID} {
      allow create: if isValidUsername();
    }
  }
}
here function isValidUsername checks for various things like length, special characters etc... but one thing I can't figure out is how to check following inside of the function
Make sure that request.resource.data.username is unique i.e. not present inside any other document of /characters collection.