Leaf delete dependency on another leaf

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.";

Thank you Waitai. This worked.