cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
166
Views
5
Helpful
1
Replies
Highlighted
Cisco Employee

Yang leaf with mac-address validation

Hi all,

 

I have a yang with a leaf that will contain a mac-address. There is in the requirement the min and max values that can be accepted ex:
min: 0000.0000.0001
max: ffff.ffff.ffff

 

I looked on the tailf_yang_extensions documentation and didn't find anything.

 

Is there a way to validate this information?

 

Thank's in advance!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Cisco Employee


I have a yang with a leaf that will contain a mac-address. There is in the requirement the min and max values that can be accepted ex:
min: 0000.0000.0001
max: ffff.ffff.ffff


I don't recognize this format. There is a built-in type called 'mac-address' defined in ietf-yang-types.yang - it is a list of octets - a typical value looks like 'aa:bb:cc:dd:ee:ff'. It is defined as 

  typedef mac-address {
    type string {
      pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}';
    }
  }

If you want to restrict such a value, you can define your own type with an appropriate pattern. For example, if you want the values to start with 'de', you can do

    typedef my-mac-address {
      type string {
        pattern 'de:[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){4}';
      }
    }

/Ram

View solution in original post

1 REPLY 1
Highlighted
Cisco Employee


I have a yang with a leaf that will contain a mac-address. There is in the requirement the min and max values that can be accepted ex:
min: 0000.0000.0001
max: ffff.ffff.ffff


I don't recognize this format. There is a built-in type called 'mac-address' defined in ietf-yang-types.yang - it is a list of octets - a typical value looks like 'aa:bb:cc:dd:ee:ff'. It is defined as 

  typedef mac-address {
    type string {
      pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}';
    }
  }

If you want to restrict such a value, you can define your own type with an appropriate pattern. For example, if you want the values to start with 'de', you can do

    typedef my-mac-address {
      type string {
        pattern 'de:[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){4}';
      }
    }

/Ram

View solution in original post