Skip to content

Instantly share code, notes, and snippets.

@udacityandroid
Created January 20, 2016 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save udacityandroid/0e255309eb72d32292f0 to your computer and use it in GitHub Desktop.
Save udacityandroid/0e255309eb72d32292f0 to your computer and use it in GitHub Desktop.
Firebase - Lesson 5 - Example Validations
{
"rules": {
".read" : "true",
".write" : "true",
"userFriends": {
"$userEncodedEmail": {
"$friendEncodedEmail": {
".validate": "newData.hasChildren(['name', 'email', 'timestampJoined', 'hasLoggedInWithPassword'])",
"name": {
".validate": "newData.isString()"
},
"email": {
".validate": "newData.isString() && newData.val().matches(/^[A-Z0-9,_%+-]+@[A-Z0-9,-]+,[A-Z]{2,4}$/i)"
},
"timestampJoined": {
".validate": "newData.hasChildren(['timestamp'])",
"timestamp": {
".validate": "newData.isNumber()"
},
"$other": {
".validate": "false"
}
},
"hasLoggedInWithPassword": {
".validate": "newData.isBoolean()"
},
"$other": {
".validate": "false"
}
}
}
},
"userLists": {
"$userEncodedEmail": {
"$listId": {
"listName": {
}
}
}
},
"users": {
"$userEncodedEmail": {
".validate": "newData.hasChildren(['name', 'email', 'timestampJoined', 'hasLoggedInWithPassword'])",
"name": {
".validate": "newData.isString()"
},
"email": {
".validate": "newData.isString() && newData.val().matches(/^[A-Z0-9,_%+-]+@[A-Z0-9,-]+,[A-Z]{2,4}$/i)"
},
"timestampJoined": {
".validate": "newData.hasChildren(['timestamp'])",
"timestamp": {
".validate": "newData.isNumber()"
},
"$other": {
".validate": "false"
}
},
"hasLoggedInWithPassword": {
".validate": "newData.isBoolean()"
},
"$other": {
".validate": "false"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment