-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Be able to reference map keys in validation rules #219
Comments
Possibly you want something like:
Slightly tricky but you have to know the first map gets a key generated of |
@rockwotj Thanks for the quick reply. I thought that might be the case...
This generates the following JSON: "post-flag": {
"$key1": {
".validate": "newData.hasChildren() && $key1.matches(/^[-_0-9a-zA-Z]{20}$/)",
"$key2": {
".validate": "$key2.matches(/^[0-9a-zA-Z]{27}[0-9]$/) && newData.isNumber() && newData.val() >= 0"
}
},
".validate": "newData.hasChildren()",
".write": "auth != null && auth.uid == key2 && newData.parent().child('post').child(key1).val() != null"
}, And error message:
|
Oops yes, good catch. I've updated my answer as well. |
So the only way I've made it to work is if duplicate the rule and use
Isn't there any sort of aliasing to instruct Bolt to map variables to certain names? Like:
|
Currently there is not, but feel free to open a PR 😄 |
I'll have a go at it. 😄 |
I'm having trouble with a DB structure that looks like this:
I'd like to validate that the data is valid and that the keys follow a certain format.
I've tried several variations of the following, but none of them really work.
For the example above I get the following JSON:
Which yields the following error in Firebase simulator:
I'm not sure if I'm writing my rules wrongly or if this is a limitation of Bolt.
The text was updated successfully, but these errors were encountered: