While mandatory works for simple choice statements (eg choice c { mandatory true; ... ), they do not work in more complex combinations.
As described in RFC 7950 Sec 7.9.4, if
if this ancestor is a case node, the constraint is enforced if any other node from the case exists.
An example of this scenario is the following:
choice c {
case ca {
leaf ca1{
type string;
mandatory true; <-----
}
leaf ca2{
type string;
}
}
}
A special case of this is if "leaf ca1" is replaced with a "choice ca".
While mandatory works for simple choice statements (eg
choice c { mandatory true; ...
), they do not work in more complex combinations. As described in RFC 7950 Sec 7.9.4, ifif this ancestor is a case node, the constraint is enforced if any other node from the case exists. An example of this scenario is the following:
A special case of this is if "leaf ca1" is replaced with a "choice ca".