Reputation: 7411
I have a list year wise inside a node. Is it possible to validate key using .validate
or something?
like I have a list like this:
"list": {
"year-2015": {
// data
},
"year-2016": {
//data
}
// etc etc
}
Can I validate key using regex /year-[0-9]{4}/
in security rules?
Upvotes: 4
Views: 770
Reputation: 58400
Yes. Validation rules can be used to validate keys.
You could define a rule like this:
{
"rules": {
"list": {
"$key": {
".validate": "$key.matches(/^year-[0-9]{4}$/)"
}
}
}
}
Upvotes: 3