{ "rules": { ".read": false, ".write": false, "highscores": { ".read": true, ".indexOn": ["score"], "$entry": { ".write": "!data.exists()", ".validate": "newData.hasChildren(['name', 'score', 'level', 'time'])", "name": { ".validate": "newData.isString() && newData.val().length >= 1 && newData.val().length <= 20" }, "score": { ".validate": "newData.isNumber() && newData.val() > 0 && newData.val() <= 10000000" }, "level": { ".validate": "newData.isNumber() && newData.val() >= 1 && newData.val() <= 999" }, "time": { ".validate": "newData.val() == now" }, "$other": { ".validate": false } } }, "users": { "$uid": { ".read": "auth != null && auth.uid == $uid", ".write": "auth != null && auth.uid == $uid" } }, "lobby": { ".read": "auth != null", "$uid": { ".write": "auth != null && auth.uid == $uid", ".validate": "newData.hasChildren(['name', 'ts'])", "name": { ".validate": "newData.isString() && newData.val().length <= 20" }, "flag": { ".validate": "newData.isString() && newData.val().length <= 4" }, "ts": { ".validate": "newData.isNumber()" }, "$other": { ".validate": true } } }, "challenges": { "$to": { ".read": "auth != null && auth.uid == $to", "$from": { ".write": "auth != null && (auth.uid == $from || auth.uid == $to)", ".validate": "!newData.exists() || (newData.child('from').val() == $from)" } } }, "matches": { "$id": { ".read": "auth != null && $id.contains(auth.uid)", ".write": "auth != null && $id.contains(auth.uid)", "state": { ".validate": "$id.beginsWith(auth.uid + '_')" }, "in": { ".validate": "$id.endsWith('_' + auth.uid)" } } } } }