# Leaf delete dependency on another leaf

**URL:** <https://dmap-community.ductus.global/t/leaf-delete-dependency-on-another-leaf/514>\
**Category:** YANG\
**Created:** [May 26, 2016, 8:28pm UTC](https://dmap-community.ductus.global/t/leaf-delete-dependency-on-another-leaf/514 "2016-05-26T20:28:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![manish.varshney](https://avatars.discourse-cdn.com/v4/letter/m/bbe5ce/32.png) [@manish.varshney](https://dmap-community.ductus.global/u/manish.varshney)\
**Post date:** [May 26, 2016, 8:28pm UTC](https://dmap-community.ductus.global/t/leaf-delete-dependency-on-another-leaf/514/1 "2016-05-26T20:28:17Z")

</div>

Hi,  
I’ve got two leaf say L1, L2.  
l2 can only be created if l1 is present (by using must in data model).  
Now that l1 and l2 is there, I see that if I execute “no” command on l1, it is deleting all l1 even though l2 is still present.

Is it possible to disable delete of l1 if l2 is present. l1 should be allowed to be deleted if l2 is not there. If l2 is present, doing no on l1 should throw dependency error.

Thanks,  
Manish

---

<div class="post-metadata">

**Author:** ![waitai](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/waitai/32/436_2.png) [@waitai](https://dmap-community.ductus.global/u/waitai)\
**Post date:** [May 27, 2016, 5:16am UTC](https://dmap-community.ductus.global/t/leaf-delete-dependency-on-another-leaf/514/2 "2016-05-27T05:16:16Z")

</div>

> [@manish.varshney](#):
>
> I’ve got two leaf say L1, L2. l2 can only be created if l1 is present (by using must in data model).Now that l1 and l2 is there, I see that if I execute “no” command on l1, it is deleting all l1 even though l2 is still present.
> 
> Is it possible to disable delete of l1 if l2 is present. l1 should be allowed to be deleted if l2 is not there. If l2 is present, doing no on l1 should throw dependency error.

If you write your must statement for L2 as follows, it will cover both of your conditions.

```
  must "../L1" {
    error-message "L2 cannot exist unless L1 is present.";
  }

```

---

<div class="post-metadata">

**Author:** ![manish.varshney](https://avatars.discourse-cdn.com/v4/letter/m/bbe5ce/32.png) [@manish.varshney](https://dmap-community.ductus.global/u/manish.varshney)\
**Post date:** [June 3, 2016, 4:24pm UTC](https://dmap-community.ductus.global/t/leaf-delete-dependency-on-another-leaf/514/3 "2016-06-03T16:24:53Z")

</div>

Thank you Waitai. This worked.
