Choice with mandatory and optional leaves not working

   container choice_demo {
      choice choice_option {
            case add_update_case {
                 leaf add {
                    mandatory true;
                    type string;
                 }
                 leaf update{
                    type string;
                 }
            }
            case del_case {
                 leaf del {
                    mandatory true;
                    type string;
                }
            }
        } // end of choice_option_2
    }   

Here I wanted a choice between add_update and delete. But in add_update I have add as mandatory param and update as optional. But it is possible to give only update in the add_update choice. Somehow add is not becoming mandatory in that choice statement.

Hello,

does it mean you can successfully commit the configuration? I guess mandatory is checked during commit time, not when you enter values in the CLI.

1 Like

Thanks. It does not allow on commit. But I wanted a mechanism to indicate clearly to user that update is optional but add is mandatory. Instead of prompting an error on commit.

I came to this option as I had a problem while writing the yang model:

Actual requirement - this works as it is not under ‘ínput’:

   container display_demo{
        leaf ena_dis {
                type enumeration{
                    enum enable;
                    enum disable;
                }
        }
        leaf disp_on_enable{
            tailf:display-when "../ena_dis = 'enable'";
            type int32;
        }
    }

But below things are not working (Same as above - but is written under input block):

  container display_demo_in{
            tailf:cli-drop-node-name;
            tailf:action display_demo_input {
                tailf:actionpoint disp-input;
                input {
                        leaf ena_dis {
                            type enumeration{
                                enum enable;
                                enum disable;
                            }
                        }
                        leaf disp_on_enable{
                            tailf:display-when "../ena_dis = 'enable'";
                            type int32;
                        }
                }
                output {
                }
            }
     }

To avoid this problem, I moved to choice option.