ConfD User Community

Leaf element data type to be either type-a or type-b


How do we define a leaf element data-type to be either of type-a or type-b

ipaddr x netmask y

Where x can be of 2 different types.

–> ipaddr netmask : netmask explicitly given : ipaddr leaf element is inet:ipv4-address
-> ipaddr : netmask derived using mask provided : ipaddr leaf element is inet:ipv4-prefix

And is it possible to suppress “netmask” if ipaddr takes type-a and be allowed if it is type-b


tried using choice

choice addr {
case type1 {
leaf ipaddr {
type inet:ipv4-prefix;
case type2 {
leaf ipaddr { <<<<<<<<<<<<<<<<<< gives error as defined under case type1
type inet:ipv4-address;
leaf netmask {
type inet:ipv4-address;



did you try to use union type?