Example
List A
{
leaf node1
{
type string ;
}
leaf-list node2
{
type leafref;
}
}
unique can be used only in case of leaf, when it is leaf list how can we validate duplicate entry of node1 and node2 in List
Example
List A
{
leaf node1
{
type string ;
}
leaf-list node2
{
type leafref;
}
}
unique can be used only in case of leaf, when it is leaf list how can we validate duplicate entry of node1 and node2 in List
Yang RFC specifies unique
can be used only for leaf
elements
https://tools.ietf.org/html/rfc6020#page-69
If you need validation for leaf-list
you may use validation point.
yang must() statement can also be used to verify potential duplicity.
e.g. if you want to make sure, that two different list rows do not have same leaf-list value
(untested pseudo-yang):
List A {
leaf node1 { type string; }
leaf-list node2 {
must "count(../../A[node2=current()]) = 1" {
tailf:dependency ".";
tailf:dependency "../node2";
error-message "Cannot have more than one identical leaf-list combinations in list A!";
}
type leafref;
}
}
i’m not sure i completely understood your duplicity between node1 and node2 - can you please elaborate and/or give example of both valid config, and of invalid one…
Thanks for the reply Joseph.
What i meant by duplicate is
Example :
Node1 = Rule1
Node2 = Add, Delete
Node1 = Rule2
Node2 = Add, Delete
Node1= Rule3
Node2= Add, Delete, Update
Here 1 and 2 are duplicate, since the leaf-list entered are exactly the same.
3 is not duplicate as the leaf-list has an extra entry
There are also some cases where we want to check combination of some fields are unique
Example:
List A
{
leaf node1
{
type string;
}
leaf-list node2
{
type leafref;
}
leaf node3
{
type string;
}
}
–
Node1 = Rule1
Node2 = Add, Delete
Node3 = Inbound
Node1 = Rule2
Node2 = Add, Delete
Node3 = Outbound
Node1= Rule3
Node2= Add, Delete
Node3 = Inbound
Here 1 and 3 are unique as the entry for Node2 and Node3 are exactly the same.
2 is different as the entry for Node3 is not the same