How to limit number of read/write records using custom claims in Firebase realtime database?

In firebase realtime database our users have a custom claim called premium this claim can have three values LEVEL_1 , LEVEL_2 or REGULAR my database rules are: { “rules”: { “.read”: “auth.token.admin === true”, “.write”: “auth.token.admin === true”, “$uid”: { “.read”: “$uid === auth.uid”, “.write”: “$uid === auth.uid”, “Boxes”:{ “Manual”:{ “.read”: “auth.token.premium === ‘REGULAR'”, “.write”:…

Details