code: @Restricted(DoNotUse.class) // called from newJob view
      public FormValidation doCheckJobName(@QueryParameter String value) {
          // this method can be used to check if a file exists anywhere in the file system,
          // so it should be protected.
          getOwner().checkPermission(Item.CREATE);
  
          if (Util.fixEmpty(value) == null) {
              return FormValidation.ok();
          }
  
          try {
              Jenkins.checkGoodName(value);
              value = value.trim(); // why trim *after* checkGoodName? not sure, but ItemGroupMixIn.createTopLevelItem does the same
              Jenkins.getInstance().getProjectNamingStrategy().checkName(value);
          } catch (Failure e) {
              return FormValidation.error(e.getMessage());
          }
  
          if (getOwner().getItemGroup().getItem(value) != null) {
              return FormValidation.error(Messages.Hudson_JobAlreadyExists(value));
          }
  
          // looks good
          return FormValidation.ok();
      }
docs: Makes sure that the given name is good as a job name.
  For use from {@code newJob}.