为什么不能在以下架构中为叶子wibble
分配默认值"-"
(不在架构中的注释,为清楚起见添加到帖子中)
module type
{
namespace "example.com";
prefix "foo";
typedef optional-value {
type union {
type uint8 {
range "0 .. 99";
}
type string {
pattern "^-$";
}
}
}
container bar {
leaf wibble {
type optional-value;
default "-"; ### NOT OKAY
}
leaf wobble {
type optional-value;
default 42; ### OKAY
}
}
}
yanglint(版本 0.16.105)不验证上述架构并返回错误消息:
err : Invalid value "-" in "wibble" element. (/type:wibble)
err : Module "type" parsing failed.
做了更多的实验,似乎不能为带有模式的字符串分配默认值
module tmp
{
namespace "example.com";
prefix "foo";
container bar {
leaf wibble {
type string {
pattern "^x$";
}
default "x"; ### NOT OKAY
}
leaf wobble {
type string;
default "y"; ### OKAY
}
}
}
杨林输出:
err : Value "x" does not satisfy the constraint "^x$" (range, length, or pattern). (/tmp:wibble)
err : Module "tmp" parsing failed.