Validation for the yang in different key-path in annotation file

Hi All,

Yang 1:

list card {
    leaf type {
	  type string; //ABC-T1,ABC-T2, BCD-A2, BCD-A4

Yang 2:

list interfaces {
     leaf name {
	    type string; // ocb-1/1/0/a<1-8>

Yang 3:

list mgmt {
    list intferface {
	 key "name";
	 leaf naem {
	    type string; // dab-1/1/0/a<1-8>
     leaf status {
         type enum; // 0, 1, 2

I have 3 yang as above:

I need to check the following

  1. In yang 1, I need to check if the last digit is even.
  2. Then when I configure yang2, if I configure ocb-1/1/0/a1, I need to check if dab-1/1/0/a<1-8> in yang 3 is configured with enum 1 and 2. If configured error must be thrown.
  3. reverese case after step 1): when I configure yang3, if I configure dab-1/1/0/a1 with enum 1 and 2, I need to check if ocb-1/1/0/a<1-8> is configured. If configured error must be thrown.

Kindly let know is it possible to do in annotation yang.


  1. yang1 leaf must statement XPath expression where something like substring(., string-length(.)) mod 2 = 0 checks if the last digit is even.
  2. & 3. A separate yang2 and yang3 leaf must statements where the XPath expressions seem straightforward.

You can, for example, annotate the YANG model with the three must statements suggested above for the three leafs.

See this old post for pointers to some relevant XPath documentation.