Compare values of enum

Hi Team,

I have below yang model ,

            container noise-level {
              description
                "Noise floor level limits";
              leaf max {
                description
                  "Maxinum noise floor level";
                tailf:cli-full-command;
                tailf:cli-trim-default;
                type enumeration {
                  enum -45dBm0 {
                    description
                      "rms value in dBm0";
                    value -45;
                  }
                  enum -50dBm0 {
                    description
                      "rms value in dBm0";
                       value -50;
                  }
                }
                default -50dBm0;
              }
              leaf min {
                description
                  "Mininum noise floor level";
                tailf:cli-full-command;
                tailf:cli-trim-default;
                type enumeration {
                  enum -55dBm0 {
                    description
                      "rms value in dBm0";
                    value -55;
                  }
                  enum -60dBm0 {
                    description
                      "rms value in dBm0";
                    value -60;
                  }
                           
                }
                default -60dBm0;
              }
              must "./min <= ./max" {
                error-message "min-noise-floor must be <= max-noise-floor";
              }
            }

Now I want to compare values of min and max . By putting must statement I am not able to achieve .

Example ,

Router(conf-voi-serv)#cpa threshold noise-level max ?
  -45dBm0  rms value in dBm0
  -50dBm0  rms value in dBm0
  -55dBm0  rms value in dBm0
  -60dBm0  rms value in dBm0

Router(conf-voi-serv)#cpa threshold noise-level max -60
Router(conf-voi-serv)#
Router(conf-voi-serv)#
Router(conf-voi-serv)#cpa threshold noise-level max -60
Router(conf-voi-serv)#cpa threshold noise-level min         
Router(conf-voi-serv)#cpa threshold noise-level min ?
  -55dBm0  rms value in dBm0
  -60dBm0  rms value in dBm0
  -65dBm0  rms value in dBm0
  -70dBm0  rms value in dBm0

Router(conf-voi-serv)#cpa threshold noise-level min -55
min-noise-floor must be <= max-noise-floor

Min should not have larger value than max .

First: the largest values of min is -55, the smallest value of max is -50, so it can never happen that the value of max is less then the value of min.

But this aside, the must expression as you have it can never work. Leaf values in XPath expressions are compared using their canonical form; and the canonical form of a enum value is its string representation. Now, when two strings are compared, they are first converted to a number using the number function, which converts a string to a meaningful number only as long as “it looks like a number”, otherwise it converts it to NaN - this is what happens in your case. So the must expression eventually compares “NaN <= NaN”, not what you intended I assume.

You may fix that by doing something like substring-before(min, 'd') - this would evaluate to e.g. '-60' which now looks like a number and the comparison would work. But since you are dealing with small set of enums, maybe you can avoid using <> altogether.