i have below yang modules, module 2 vlan should be present in module 1 vlan. please suggest me how i can write the comparison logic correctly so that it can compare the exact value.
example:
entry vlan 2055,2056 ===> (value is string)
vlan 2055 ===> (value is integer (it can be 'vlan 5 or vlan 20 or vlan 55 or vlan 56') for all
value it should work correctly)
note: module 1 type is string, module 2 type is integer.
module-1:
list entry {
key vlan;
leaf vlan {
type string {
pattern '' ====> it can allow 1-4096 value with combination of range, comma e.g: 1,10-15 or 2053,2054
}
}
Module 2:
list vlan {
key vlan;
leaf vlan {
type uint16 {
range "1..4096"
}
}
Assuming your goal is to validate the configuration of module 2 VLAN as being contained in at least one of the list entries of module 1, this looks like a similar situation as described in the User Guide, Section 12.7 Validating Data in C, although more complex.
If you have the option, you might think about restructuring module 1 to just be a simple list of vlans and then you can probably make use of built-in features such as MUSTs or leaf-refs to ensure that module 2 vlans already exist in the module 1 list.