Enable and Disable MenuItem Depends upon Selected Transform

Hi,
I wanted to create a menu item which should be enable when transform is selected. I write the small code snippet like below.

But I couldn’t find that menu item at all in menu.

[MenuItem("MyName/Assets/CreatePrefab",true)] 
static bool CreatePrefab()
{
        return Selection.activeTransform != null;
}

I tried the another way.I see the menu item always enable, can’t see disable…

[MenuItem("MyName/Assets/CreatePrefab",false)] 
static bool CreatePrefab()
{
    return Selection.activeTransform != null;
}

Could you anyone help me in this please? Thanks in advance

Do this:

 [MenuItem("MyName/Assets/CreatePrefab")]
 // main method go here 
   
 [MenuItem("MyName/Assets/CreatePrefab",true)]
 static bool CheckIfMainMethodIsValid() {
    return //*true if menu item should be available*//
 }

Thanks for reply Yash,

  [MenuItem("MyName/Assets/CreatePrefab",true)]                           
   static bool CreatePrefab() {                                           
       return Selection.activeTransform != null;
   }

I had already tried this , I could not find that menuitem at all in menu whether the transform selected or not.

To any one still struggling with this, please refer to the below Example:
image