Last active
October 17, 2017 12:08
-
-
Save georgesboris/99774def71c848fd1d7fc94d72858f3d to your computer and use it in GitHub Desktop.
firebase-app - rules - paths
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const paths = require('./paths') | |
const { validate, newData, isAuth, isAuthId, isString, isNow } = require('firebase-rules/helpers/common'); | |
module.exports = { | |
__setup__: 'paths', | |
// this is a shorthand for { read: 'auth.uid != null' } | |
[paths.posts]: isAuth, | |
// these are shorthands for { validate: ... } | |
[paths.post('$postId')]: validate(hasChildren(['title', 'body', 'createdAt', 'createdBy'])), | |
[paths.postTitle('$postId')]: validate(isString), | |
[paths.postBody('$postId')]: validate(isString), | |
[paths.postCreatedAt('$postId')]: validate(isNow) | |
[paths.postCreatedBy('$postId')]: validate(isAuthId(newData)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment