a choice statement with three possible cases have been defined in a yang. I would like to restrict a particular case based on the value of another leaf in the yang.
Since deviation
or deviate
statement does not have condition (when
statement) to check values in another leaves, I do not think it is possible to achieve it through deviation
.
What you may try is to use augment
, which can check values. E.g. from RFC8022
augment "/rt:routing-state/rt:ribs/rt:rib/rt:routes/rt:route" {
when "../../rt:address-family = 'v4ur:ipv4-unicast'";
description
"This leaf augments an IPv4 unicast route.";
leaf destination-prefix {
type inet:ipv4-prefix;
description
"IPv4 destination prefix.";
}
}
So your augments might look like:
augment "path to choice" {
when "condition1";
case mycase1 {
...
}
}
augment "path to choice" {
when "condition2";
case mycase2 {
...
}
}