How to make a leaf to accept both ipv4 address and the name

leaf abc {
            
          }

how to make this what type should be used

I assume you mean ipv4 address or name (one of these at a time) -> YANG union type where you can list several types that are acceptable. See example in YANG RFC…

can you please give a example here correct me if i’m wrong
leaf abc {
type type inet:ipv4-address;
inet:domain-name ;

   }

type inet:domain-name ;