Make container as optional

Hi ,

Is it possible to make container “SwitchPort” as optional (even with one of the members of the container as mandatory) so that commit is allowed even without configuring mandatory element “location” below yang schema.

please suggest if any options available.

module test-switch {
yang-version 1.1;
namespace “urn:test-switch”;
prefix “Switch”;

container SwitchPort {  //optional 
    leaf name { //optional
        type string;   
    }
    leaf location { //mandatory
        type string;   
        mandatory "true";
    }
}

}

Thanks,
Raja

Make it a presence container:
More details in the RFC.

container SwitchPort { //optional
presence “Enables switch port configuration”;
leaf name { //optional
type string;
}
leaf location { //mandatory
type string;
mandatory “true”;
}
}

Also double check the container name “SwitchPort” => check “Identifier Naming Conventions” in RFC 8407 - Guidelines for Authors and Reviewers of Documents Containing YANG Data Models

thanks Nabil, it works