Reputation: 87
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. Ex : 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.
Please let me know if there is a way of accomplishing this ?
Thanks, Vinayak
Upvotes: 0
Views: 438
Reputation: 87
The solution for this would be using "mod" operator.
leaf range-limit {
type uint16 {
range "10..1000";
}
must ". mod 10 = 0" {
error-message "Value should be multiple of 10";
}
default 100;
}
Upvotes: 1