<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Making leaf node Conditional mandatory in yang in Tools</title>
    <link>https://community.cisco.com/t5/tools/making-leaf-node-conditional-mandatory-in-yang/m-p/4575012#M1540</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to make a leaf node as conditional mandatory as explained below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;list top-list {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;STRONG&gt;leaf type&lt;/STRONG&gt; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;description "type.";&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;mandatory true;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;type network-type; /// this type has 3 values i.e local/remote/gr-remote&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;STRONG&gt;leaf node&lt;/STRONG&gt; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;description "Node details.";&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;type leafref {&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; path /// -- some reference&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;mandatory&lt;/STRONG&gt; true;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;when "../type = 'local'";&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now here, the ask is to have &lt;STRONG&gt;node&lt;/STRONG&gt; as mandatory when &lt;STRONG&gt;type&lt;/STRONG&gt;&amp;nbsp;is local and &lt;STRONG&gt;optional&lt;/STRONG&gt; when type is gr-remote and not allowed when type is local.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am able to make both local &amp;amp; gr-remote as either mandatory or option via using "when" but not able to make leaf "&lt;STRONG&gt;node"&lt;/STRONG&gt;&amp;nbsp;as mandatory when &lt;STRONG&gt;type&lt;/STRONG&gt;&amp;nbsp; is "local" and optional when &lt;STRONG&gt;type&lt;/STRONG&gt; is "gr-remote".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any leads on this would be helpful.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Nikhil&lt;/P&gt;</description>
    <pubDate>Mon, 21 Mar 2022 12:23:42 GMT</pubDate>
    <dc:creator>nikhilagarwal.85</dc:creator>
    <dc:date>2022-03-21T12:23:42Z</dc:date>
    <item>
      <title>Making leaf node Conditional mandatory in yang</title>
      <link>https://community.cisco.com/t5/tools/making-leaf-node-conditional-mandatory-in-yang/m-p/4575012#M1540</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to make a leaf node as conditional mandatory as explained below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;list top-list {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;STRONG&gt;leaf type&lt;/STRONG&gt; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;description "type.";&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;mandatory true;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;type network-type; /// this type has 3 values i.e local/remote/gr-remote&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;STRONG&gt;leaf node&lt;/STRONG&gt; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;description "Node details.";&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;type leafref {&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; path /// -- some reference&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;mandatory&lt;/STRONG&gt; true;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;when "../type = 'local'";&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now here, the ask is to have &lt;STRONG&gt;node&lt;/STRONG&gt; as mandatory when &lt;STRONG&gt;type&lt;/STRONG&gt;&amp;nbsp;is local and &lt;STRONG&gt;optional&lt;/STRONG&gt; when type is gr-remote and not allowed when type is local.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am able to make both local &amp;amp; gr-remote as either mandatory or option via using "when" but not able to make leaf "&lt;STRONG&gt;node"&lt;/STRONG&gt;&amp;nbsp;as mandatory when &lt;STRONG&gt;type&lt;/STRONG&gt;&amp;nbsp; is "local" and optional when &lt;STRONG&gt;type&lt;/STRONG&gt; is "gr-remote".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any leads on this would be helpful.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Nikhil&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2022 12:23:42 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/making-leaf-node-conditional-mandatory-in-yang/m-p/4575012#M1540</guid>
      <dc:creator>nikhilagarwal.85</dc:creator>
      <dc:date>2022-03-21T12:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: Making leaf node Conditional mandatory in yang</title>
      <link>https://community.cisco.com/t5/tools/making-leaf-node-conditional-mandatory-in-yang/m-p/4583367#M1541</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/1330224"&gt;@nikhilagarwal.85&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;I see that no YANG experts have commented so I'll make a suggestion. You might want to try the 'refine' statement and/or the 'default' sub-statement as described in these two StackOverflow discussions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://stackoverflow.com/questions/45967768/how-to-refine-the-mandatory-property-of-nodes-from-a-grouping-in-yang-language" target="_blank"&gt;How to refine the mandatory property of nodes from a grouping in YANG language?&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://stackoverflow.com/questions/35907872/conditional-assignment-of-default-values-in-yang" target="_blank" rel="noopener"&gt;Conditional assignment of default values in yang&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 20:28:31 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/making-leaf-node-conditional-mandatory-in-yang/m-p/4583367#M1541</guid>
      <dc:creator>Alexander Stevenson</dc:creator>
      <dc:date>2022-03-31T20:28:31Z</dc:date>
    </item>
  </channel>
</rss>

