Eduardo Spagna
Eduardo Spagna

Reputation: 39

Problems with hasChild() using bolt compiler

I need to verify that the 'category' attribute has its value equal to a key existing on the category node

I tried this:

type VerifyCategoryExists extends String { validate() { prior(root.categories['categories-list'][this]) != null } } }

That generated this:

".validate": "(newData.isString() && root.child('categories').child('categories-list').child(data.val()).val() != null)"

But I wanted this (I tested without using the bolt and it worked):

".validate": "(newData.isString() && root.child('categories').child('categories-list').hasChild(newData.val()))"

How do I get to the expected result but using the bolt?

Upvotes: 0

Views: 36

Answers (1)

Eduardo Spagna
Eduardo Spagna

Reputation: 39

After a long time, I tried it and it worked the way I wanted it

type VerifyCategoryExists extends String {
    validate() { prior(root.categories['categories-list'])[this] != null }
}

Upvotes: 1

Related Questions