ConfD User Community

Makes leafs mutually exclusive


How can i make the leaves ‘one’ and ‘two’ mutually exclusive to each other.

list test-list {
leaf one {
type string;

leaf two {
type string;


The label of "choice " maybe satisfy your require.

RFC 6020 description as below:

4.2.7. Choices
YANG allows the data model to segregate incompatible nodes into
distinct choices using the “choice” and “case” statements. The
“choice” statement contains a set of “case” statements that define
sets of schema nodes that cannot appear together. Each “case” may
contain multiple nodes, but each node may appear in only one “case”
under a “choice”.
When an element from one case is created, all elements from all other
cases are implicitly deleted. The device handles the enforcement of
the constraint, preventing incompatibilities from existing in the
The choice and case nodes appear only in the schema tree, not in the
data tree or NETCONF messages. The additional levels of hierarchy
are not needed beyond the conceptual schema.

 container food {
   choice snack {
       case sports-arena {
           leaf pretzel {
               type empty;
           leaf beer {
               type empty;
       case late-night {
           leaf chocolate {
               type enumeration {
                   enum dark;
                   enum milk;
                   enum first-available;