I would like to prevent user/hacker from :
- Writing a document with a doc name that already exist ( docs names are custom strings not Auto UserIDs)
- Writing a document that contains an email field that already exist.
Assuming i can't normalize the database ( there are too many requirements and normalizing one ruin the other).
Can i create rules for these ? especially number 2 ?
Or, should i instead create a Cloud Function that do that after reading DB, without any rule ?
Which approach is more "right" ?
1.
Docs
John:{}
Johnny:{}
John:{} // *** prevent another john
2.
Docs
abcd:{email:xyz}
efgh:{email:xyz} // *** prevent this one