bolt icon indicating copy to clipboard operation
bolt copied to clipboard

Does not generate .val() if inside beginsWith

Open FrankChung opened this issue 8 years ago • 2 comments

My bolt file:

path /test is Test {}

type Test {
  validate() { this.beginsWith(this) }
}

output json:

{
  "rules": {
    "test": {
      ".validate": "newData.val().beginsWith(newData)"
    }
  }
}

FrankChung avatar Aug 16 '16 06:08 FrankChung

Work around:

this.beginsWith(this + '')

mckoss avatar Aug 16 '16 14:08 mckoss

FYI this seems to be an issue with other functions as well. Fortunately the workaround provided by @mckoss circumvents this issue.

Input bolt:

path /foo/{bar} {

    write() {

        this.bar[getBar(bar).bar] != null

    }
}

getBar(bar) {
    return prior(root).bars[bar]
}

output json:


{
  "rules": {
    "foo": {
      "$bar": {
        ".write": "newData.child('bar').child(root.child('bars').child($bar).child('bar')).val() != null"
      }
    }
  }
}

bpinney avatar Mar 01 '17 19:03 bpinney