Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple RTDB validation example
{
"aListOfRecords": {
// when querying our list, must get less than 50 at a time and be authenticated
".read": "auth != null && (query.limitToFirst <= 50 || query.limitToLast <= 50)",
"$aRecordId": {
// When fetching a single record, I must be logged in
".read": "auth != null",
// When writing a record, I must be logged in
".write": "auth != null",
// Validate my schema
"aNumberField": { ".validate": "newData.isNumber() && newData.val() > -1 && newData.val() < 51" },
"aStringField": { ".validate": "newData.isString() && newData.val().length < 4" }
// Disallow any fields not in my schema
"$other": { ".validate": false }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.