I’ve added a “refine” and “must” when “uses” refers to a group. An example of how it’s being used is as follows :
uses bird-config {
refine feathers-count {
must '(. = 3000)' {
error-message "Invalid number of feathers";
}
}
}
Where the grouping "bird-config" is defined as:
grouping bird-config {
description
"Per bird configuration data.";
leaf bird-name {
type species:birds;
description
"[adapted from IETF BIRD model RFC 0000]
The bird name.";
}
leaf feathers-count {
type uint8 {
range "0..3000";
}
mandatory true;
description
"[adapted from IETF BIRD model RFC 0000]
The number of feathers.";
}
}
Why is error not being thrown with this simple refine-must statement when I input numbers that aren’t 3000 in feathers-count?
I've tried double-quoting feathers-count in refine and double-quoting the must conditional statement instead of single quotes. I expected that when I run a configuration with an input number that isn't 3000 for feathers-count, an error should be thrown and the configuration should not apply, but what resulted was the configuration being seamlessly applied.
It is a bug in the implementation you are using or you have not configured it properly.
Your YANG definitions are invalid. The range of a unit8 integer built in type is
0..255.3000will never fit in there and the tool you are using should have produced an error for this range statement:My guess would be that the implementation you are using is ignoring XPath expressions entirely. You are correct in your assumption that a validation error should have been reported for an expression that evaluates to
false().