Validation to check a leaf value is configured or not

I need a condition like whenever the username is configured the password must be configured.

 leaf username {
        error-message "Password should be configured.";
      type string {
        length "5..16";
      default "admin";
    leaf password {
      type ianach:crypt-hash;

So, since the username leaf has a default, i.e. “admin”, you apparently do not require a password in the case of the default being in effect (since no username has been configured in that case), correct?

But do you require a password when

a) a username other than “admin” has been configured


b) any username, including “admin”, has been configured?

And is this your actual, complete model for this configuration, i.e. there is only one username and one password to be configured, and not the more common case of having a list with username as key (in which case it can’t have a default)?