Feel expression to spilt and evaluate an array of strings

Hi,
I have an input string array of fruits and quantities as CSV strings e.g. -

{>

“fruits”:[“apple,1”,“banana,2”,“pineapple,3”]
}

I want to make sure that the array always contains at least 5 apples and 2 bananas. I am able to do this with the following feel expressions -

(some item in fruits satisfies (split(item, “,”)[1] = “apple” and number(split(item, “,”)[2]) >= 5)) and (some item in fruits satisfies (split(item, “,”)[1] = “banana” and number(split(item, “,”)[2]) >=2))

I am wondering if this is the right way of doing this predicate or are there better (or more idiomatic) way of doing this.

Hi @venkyvb

I would use the same expression as yours.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.