Empty String representations in Yang

In our existing code, we have mac-address lists where an entry can be an empty string “” which indicates that it matches any mac address. We also have IP lists. So you can have an IP + MAC to match against, or IP + any mac address==“”. I didn’t see a definitive answer on this and thought I’d ask.

I wanted to understand the capability of Yang to express this.

  1. I know one representation of this is the leaf not being present, but since they are correlated above with the IP address, that doesn’t work well.
  2. Is it possible to assign the value of “null string” to a string based value from the confd CLI? We could not figure out a way to enter it.
  3. What is the regex that will allow this. We did get a regex string that seemed to work with the compiler, but it did not allow the entry of “” as the value.

Here is the regex we are using:
typedef tolt-mac-address-or-empty {
type string {
pattern ‘([0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5})?’;
}
description
“MAC address in standard colon-separated format (e.g., 00:1A:2B:3C:4D:5E)
or an empty string.”;
}

seems to work fine on my side?
(I’ve added your leaf into existing example in examples.confd/intro/1-2-3-start-query-model/)

admin connected from 127.0.0.1 using console on DEV
DEV# config
Entering configuration mode terminal
DEV(config)# dhcp tolt-mac-address-or-empty 11:22:33:44:55
--------------------------------------------------------^
syntax error: "11:22:33:44:55" is an invalid value.
DEV(config)# dhcp tolt-mac-address-or-empty 11:22:33:44:55:66
DEV(config)# dhcp tolt-mac-address-or-empty ""
DEV(config)# commit
Commit complete.
DEV(config)# show full-configuration dhcp
dhcp tolt-mac-address-or-empty ""
DEV(config)#

edit: to clear potential confusion on presence of quotes, adding another way to display value using confd_cmd:

user@DEV:~/examples.confd/intro/1-2-3-start-query-model$ confd_cmd -c "get /dhcp/tolt-mac-address-or-empty"

user@DEV:~/examples.confd/intro/1-2-3-start-query-model$ confd_cmd -c "get /dhcp/tolt-mac-address-or-empty" | wc -c
1
// one EOF/newline character...