# Issue with 'must' constraint

**URL:** <https://dmap-community.ductus.global/t/issue-with-must-constraint/3359>\
**Category:** YANG\
**Created:** [November 2, 2020, 4:23am UTC](https://dmap-community.ductus.global/t/issue-with-must-constraint/3359 "2020-11-02T04:23:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saswat](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/saswat/32/291_2.png) [@Saswat](https://dmap-community.ductus.global/u/Saswat)\
**Post date:** [November 2, 2020, 4:23am UTC](https://dmap-community.ductus.global/t/issue-with-must-constraint/3359/1 "2020-11-02T04:23:01Z")

</div>

Hello,

I have a `tailf:action` with `input` block that takes 3 leaf nodes: vpn-id, source-ip and interface. I have a constraint that vpn-id must be configured if the interface is configured. Both vpn-id and interface are of type leafref, pointing to a valid config tree.

```auto
    input {
      leaf vpn-id {
        type leafref {
          path "<valid-path-here>";
          tailf:cli-expose-key-name;
        }
      }
      leaf interface {
        must "(../vpn-id)" {
          error-message "vpn-id must be configured";
         }
         type leafref {
           path "<valid path here>";
         }
       }
       leaf source-ip { };
     }

```

1. When I configure only interface and give a ‘?’, it shows `cr` even though vpn-id is not configured. The command shouldn’t show `cr` unless vpn-id is configured when the interface is also configured. How can I fix it?

2. If I hit enter after configuring only the interface, instead of throwing the error-message under `must`, it throws the `Error: illegal reference` which I believe is coming from the leafref of `interface`. How can I print the error-message under `must` instead of the illegal reference error?

Please suggest.

---

<div class="post-metadata">

**Author:** ![mvf](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/mvf/32/182_2.png) [@mvf](https://dmap-community.ductus.global/u/mvf)\
**Post date:** [November 2, 2020, 9:35am UTC](https://dmap-community.ductus.global/t/issue-with-must-constraint/3359/2 "2020-11-02T09:35:30Z")

</div>

1. You may try to wrap the leafs in a container annotated with `cli-drop-node-name`, `cli-sequence-commands`, `cli-compact-syntax` - this would force the user to provide the leafs in the order as they are modeled. Note though that actions are not particularly good tool for modeling CLI commands, if your primary interface is CLI, maybe you should use clispec-modeled commands instead.

2. ConfD does not report all constraint violations, it reports just the first one that it detects. If you provide correct interface leafref but do not provide `vpn-id`, ConfD reports the must error message.

---

<div class="post-metadata">

**Author:** ![Saswat](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/saswat/32/291_2.png) [@Saswat](https://dmap-community.ductus.global/u/Saswat)\
**Post date:** [November 5, 2020, 5:09am UTC](https://dmap-community.ductus.global/t/issue-with-must-constraint/3359/3 "2020-11-05T05:09:47Z")

</div>

Can we use `cli-compact-syntax` in actions? The compilation throws error if I do so.  
Also, I tried to model the yang as per your suggestion(except the cli-compact-syntax because it didn’t compile) but I still see the `cr` in the possible completions.

```
container debug {
   tailf:action filter {
     tailf:actionpoint ap;
     tailf:cli-operational-mode;
     input {
      container interface {
        tailf:cli-drop-node-name;
        tailf:cli-sequence-commands;
        tailf-cli-compact-syntax;
        leaf ingress-if { };
        leaf vpn-id { };
      }
      leaf source-ip { };
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![mvf](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/mvf/32/182_2.png) [@mvf](https://dmap-community.ductus.global/u/mvf)\
**Post date:** [November 5, 2020, 11:13am UTC](https://dmap-community.ductus.global/t/issue-with-must-constraint/3359/4 "2020-11-05T11:13:29Z")

</div>

For that you can use `tailf:cli-incomplete-command`.
