# Must statement fails

**URL:** https://dmap-community.ductus.global/t/must-statement-fails/1593
**Category:** YANG
**Created:** [October 16, 2017, 5:23am UTC](https://dmap-community.ductus.global/t/must-statement-fails/1593 "2017-10-16T05:23:42Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![evyatar](https://avatars.discourse-cdn.com/v4/letter/e/958977/32.png) [@evyatar](https://dmap-community.ductus.global/u/evyatar)
#### Post date: [October 16, 2017, 5:23am UTC](https://dmap-community.ductus.global/t/must-statement-fails/1593/1 "2017-10-16T05:23:42Z")

</div>

Hi,

In my module I have the following definition:

```auto
        container private-as-handling {
        must "../../peer-group[peer-group-name=current()]/peer-parameters/peer-type ='EXTERNAL'";
            description "private AS in AS_PATH treatment: replacing,removing or doing nothing";
            leaf enable {
                description "enable or disable handling of private AS";
                type boolean;
                default false;
            }
            leaf remove-private-as {
                type eci-bgp-types:remove-private-as-option;
                description
                "Remove or replace private AS numbers from updates sent to peers.";
            }
        }
        leaf minimum-advertisement-interval {
            type int32 {
                range "1..3600";
            }
        must "../../peer-group[peer-group-name=current()]/peer-parameters/peer-type ='EXTERNAL'";
            default 30;

```

I don’t set the container private-as-handling nor the leaf minimum-advertisement-interval and I am using peer-type == INTERNAL.  
I suspect that the problem is that confd sets these container & leaf by default to default values and therefore the must statement fails:

Aborted: ‘routing control-plane-protocols control-plane-protocol bgp master bgp peer-groups peer-group ibgp minimum-advertisement-interval’ (value “30”): the ‘must’ expression “…/…/peer-group[peer-group-name=current()]/peer-parameters/peer-type =‘EXTERNAL’” failed

Is there any solution for that?

Thanks,

Evyatar Wiesel

---

<div class="post-metadata">

### Author: ![cohult](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/cohult/32/221_2.png) [@cohult](https://dmap-community.ductus.global/u/cohult)
#### Post date: [October 16, 2017, 8:59am UTC](https://dmap-community.ductus.global/t/must-statement-fails/1593/2 "2017-10-16T08:59:53Z")

</div>

Since you are not using a “when” statement here, I assume you want the “must” statement’s XPath expression to be valid if the leaf value matches the default value. Then try something like:

```auto
must ". = 30 or ../../peer-group[peer-group-name=current()]/peer-parameters/peer-type ='EXTERNAL'";

```

---

<div class="post-metadata">

### Author: ![evyatar](https://avatars.discourse-cdn.com/v4/letter/e/958977/32.png) [@evyatar](https://dmap-community.ductus.global/u/evyatar)
#### Post date: [December 6, 2017, 7:24am UTC](https://dmap-community.ductus.global/t/must-statement-fails/1593/3 "2017-12-06T07:24:38Z")

</div>

Hi,

I would like the must statement to be valid only in case user set this value.  
If user didn’t set minimum-advertisement-interval the validation should be true.

Thanks,  
Evyatar
