Must statement with count

must “(count(…/secu:group = ‘level-4’) >= 1)” {

count the number of level-4 users in user group. The count with another rule within it fails in confd.

In the ConfD example $CONFD_DIR/examples.confd/validate/xpath_must there are a few examples of must statements with rules within rules. The README in that example contain a couple of tips on how to debug your XPath expression.

Guessing a bit since I don’t have your YANG model, assuming your “secu:group” is a list with a user leaf that is not your key, your expression would look something like this:

must "(count(../secu:group[user = 'level-4']) >= 1)" {