Skip to content

Instantly share code, notes, and snippets.

@georgesboris
Last active October 17, 2017 12:08
Show Gist options
  • Save georgesboris/99774def71c848fd1d7fc94d72858f3d to your computer and use it in GitHub Desktop.
Save georgesboris/99774def71c848fd1d7fc94d72858f3d to your computer and use it in GitHub Desktop.
firebase-app - rules - paths
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