Yang validation: value comparison between string and integer

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.

Also note that there are multiple “validation from code” examples in the ConfD example set:

$ find examples.confd -name "*.yang" |xargs grep "tailf:validate"
examples.confd/validate/python/mtest.annot.yang:    tailf:validate vp1;
examples.confd/validate/c_dependency/mtest.yang:      tailf:validate vp1 {
examples.confd/validate/c_dependency/mtest.yang:      tailf:validate vp2 {
examples.confd/validate/c_dependency/mtest.yang:      tailf:validate vp3 {
examples.confd/validate/c_dependency/mtest.yang:    tailf:validate vp3 {
examples.confd/validate/c_dependency/mtest.yang:    tailf:validate vp4 {
examples.confd/validate/c/mtest.annot.yang:    tailf:validate vp1;
examples.confd/intro/python/12-maapi/maapi-example.yang:            tailf:validate val-items {
examples.confd/intro/12-c_maapi/maapi-example.yang:            tailf:validate val-items {
examples.confd/intro/java/12-maapi/maapi-example.yang:            tailf:validate val-items {
examples.confd/intro/java/4-stats/jdemo.yang:        tailf:validate validate-ip {
examples.confd/intro/java/4-stats/jdemo.yang:        tailf:validate validate-port {
examples.confd/logging_framework/logging-model.yang:      tailf:validate logging-config-val {
examples.confd/logging_framework/logging-model.yang:      tailf:validate logging-config-val {
examples.confd/logging_framework/logging-model.yang:      tailf:validate logging-config-val {
examples.confd/cli/display_groups/jdemo.yang:        tailf:validate validate-ip {
examples.confd/cli/display_groups/jdemo.yang:        tailf:validate validate-port {
examples.confd/cli/climods/test.yang:            tailf:validate vp1 {
examples.confd/linuxcfg/ietf_system/ietf-system-ann.yang:        tailf:validate system_tz {
1 Like