bolt
bolt copied to clipboard
`this` and `prior(this)` are ignored in functions
An example test.bolt,
path /unchangeable1 {
write() { isTheSame() }
}
path /unchangeable2 {
write() { prior(this)==this }
}
isTheSame() { prior(this)==this }
renders to the following,
{
"rules": {
"unchangeable1": {
".write": "this == this"
},
"unchangeable2": {
".write": "data.val() == newData.val()"
}
}
}
Am I missing the idea or should unchangeable1 be rendered the same as unchangeable2?
This should probably return an error at compile time. I think the issue is that the value of 'this' is defined inside a validation or write rule, but is not bound in the function.
To get around this, you can pass this as a parameter to your function instead.