Built-in function to validate the input against power of 2?

Is there YANG built-in function to validate the input against power of 2 which i can use in MUST condition ?

If you mean non-negative integers, then yes, kind of. Note that only for powers of 2 it holds that band(x, x-1) = 0; band is bitwise and, ConfD XPath extension (see the documentation for tailf_yang_extensions).

For general input validation you may want to look at user-defined types that allow you to implement any kind of input validation you might need (see the documentation for confd_types and the example misc/user_types). A must statement is obviously simpler to implement, but a) it might not be always possible to use that b) it is not really an input validation, the value might be passed to some of your application callbacks before it is finally refused by ConfD.

2 Likes

Thank you, was not aware of bitwise operation with YANG