简体   繁体   English

在杨建模中,我想实现一个叶子,它可以接受 10 到 1000 范围内的值,以 10 的倍数

[英]In Yang Modelling, I want to implement a leaf which can accept values from range 10 to 1000 in multiples of 10

In Yang Modelling, I want to implement a leaf(as shown below) which can accept values ranging from 10 to 1000. The catch here is the value should be in multiple of 10's.在 Yang Modelling 中,我想实现一个叶子(如下所示),它可以接受从 10 到 1000 的值。这里的问题是值应该是 10 的倍数。 Ex : 10,20,30,40...1000例如:10,20,30,40...1000

My current leaf structure is :我目前的叶子结构是:

  leaf range-limit {
    type uint16 {
      range "10..1000";
    }
    default 100;
  }

To implement this requirement, I thought if defining an enum which would hold all these values beginning from 10,20,30 etc....uptil 1000. But this enum would look too long and though might not be the ideal way of doing it.为了实现这个要求,我想如果定义一个枚举来保存从 10、20、30 等开始的所有这些值......直到 1000。但是这个枚举看起来太长了,虽然可能不是理想的方法.

Please let me know if there is a way of accomplishing this ?请让我知道是否有办法做到这一点?

Thanks, Vinayak谢谢,维纳亚克

The solution for this would be using "mod" operator.解决方案是使用“mod”运算符。

leaf range-limit {
    type uint16 {
      range "10..1000";
    }
    must ". mod 10 = 0" {
      error-message "Value should be multiple of 10";
    }
    default 100;
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM