Check value is even or odd

Hi Team,
I have below yang model,

          container port-range {
            tailf:cli-flatten-container;
            leaf startport{
              tailf:cli-drop-node-name;
              type uint16 {
                range "8000..48198";
              }
            }
            leaf endport {
              tailf:cli-drop-node-name;
              type uint16 {
                range "8000..48198";
              }
            }
          }

Now if any of startport or endport is not even it should give proper error message like below,

Router(conf-voi-serv)#$port-range 8001 8003
% min_port value must be even, setting to 8002
% max_port value must be even, setting to 8002

I tried by putting must statement like

must "min /2 = 0" {
   error-message "";
}

But this is not working . How to achieve same . Please response at the earilest.

Your must expression when added to the startport leaf should look like . mod 2 = 0. But a must cannot correct the value, if you need such functionality, you have to use other mechanisms such as transaction hooks.

Thanks mvf . Can you please guide me how this transaction hooks works?As I want to set the value as well.

See ConfD UG, chapter “Transformations, Hooks, Hidden Data and Symlinks” and examples.confd/intro/11-c_hooks