Validate the instance service name.

@param name
the service name String.
@throws ServiceException
428622
public static void validateServiceName(String name) throws ServiceException {
        if (!validateRequiredField(name, nameRegEx)) {
            throw new ServiceException(
                    ErrorCode.SERVICE_INSTANCE_NAME_FORMAT_ERROR);
        }
    }
1101747
public static void validateProvidedServiceInstance(
            ProvidedServiceInstance serviceInstance) throws ServiceException {
        
        if (serviceInstance == null) {
            throw new ServiceException(
                    ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR,
                    ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR.getMessageTemplate(),
                    "service instance");
        }
               
        validateServiceName(serviceInstance.getServiceName());
        validateURI(serviceInstance.getUri());
        validateAddress(serviceInstance.getAddress());
        
        if (serviceInstance.getMetadata()!=null) { //allow metadata as null
            validateMetadata(serviceInstance.getMetadata());
        }
    }
1084697
protected function validateService($serviceName, $methodName, $arguments = array())
    {
        $service = $this->container->get($serviceName);
        if (!is_callable(array($service, $methodName))) {
            throw new \UnexpectedValueException("Method $methodName not found in class " . get_class($service) . " implementing service $serviceName");
        }
    }
1319495
public function isValid($name)
    {
        return is_string($name) && (preg_match(static::SERVICE_PATTERN, $name) || isset($this->app[$name]));
    }
825027
public void validateName(final String name) {
        Validate.validState(
                TENANT_NAME_VALIDATOR_PATTERN.matcher(name).matches(),
                "Invalid tenant name '%s'  -- names must match %s .",
                name,
                TENANT_NAME_VALIDATOR_REGEX);
    }
1077179
@Override
    public Collection<ServiceInstance<T>> queryForInstances(String name) throws Exception
    {
        return queryForInstances(name, null);
    }
546035
public static void validateAttributeName(String name) {
    checkForKeyword(name);

    validateName(name);

    if (!name.matches("[a-zA-Z0-9_#]+(-[a-z]{2,3})??$")) {
      throw new MolgenisDataException(
          "Invalid characters in: ["
              + name
              + "] Only letters (a-z, A-Z), digits (0-9), underscores (_) and hashes (#) are allowed.");
    }
  }
559768
private void lookupInstance(String args[]) {
        String serviceName = args[1];
        System.out.println("lookupInstance, serviceName=" + serviceName);
        try {
            ServiceInstance instance = ServiceDirectory.getLookupManager().lookupInstance(serviceName);
            printServiceInstance(instance);
        } catch (ServiceException e) {
            e.printStackTrace();
            fail(e.getServiceDirectoryError().getErrorMessage());
        }
    }
1133477
public void remove(String name) {
        EndpointService<L, S> service = endpointServices.remove(name);
        if (service != null) {
            service.stop();
            log.infoRemovedEndpointService(service.toString());
        }
    }
31679
public void setServiceNames(java.util.Collection<String> serviceNames) {
        if (serviceNames == null) {
            this.serviceNames = null;
            return;
        }

        this.serviceNames = new com.amazonaws.internal.SdkInternalList<String>(serviceNames);
    }
595532
@Override
	public void setName(String name) {
		if (name == null) {
			super.setName(getFirstFreeBusStopName(getContainer()));
		} else {
			super.setName(name);
		}
	}
1335423
public void validateFname(final String fname) {
        Validate.validState(
                TENANT_FNAME_VALIDATOR_PATTERN.matcher(fname).matches(),
                "Invalid tenant fname '%s'  -- fnames must match %s .",
                fname,
                TENANT_FNAME_VALIDATOR_REGEX);
    }
529667
@Override
	public void setName(String name) {
		if (name == null) {
			super.setName(getFirstFreeBusLineName(getContainer()));
		} else {
			super.setName(name);
		}
	}
10444
private void validateName(String name) throws DDFException {
    Boolean isNameExisted;
    try {
      this.getManager().getDDFByName(name);
      isNameExisted = true;
    } catch (DDFException e) {
      isNameExisted = false;
    }
    if(isNameExisted) {
      throw new DDFException(String.format("DDF with name %s already exists", name));
    }

    Pattern p = Pattern.compile("^[a-zA-Z0-9_-]*$");
    Matcher m = p.matcher(name);
    if(!m.find()) {
      throw new DDFException(String.format("Invalid name %s, only allow alphanumeric (uppercase and lowercase a-z, " +
          "numbers 0-9) and dash (\"-\") and underscore (\"_\")", name));
    }
  }
672714
public Service getService(String name) {
        Service service = store.get(name);
        if (service == null) {
            throw HttpException.notFound("Service not found for name '" + name + "'");
        }
        return service;
    }
1219598
private function validateName($name) {
        if (!is_string($name))    throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name));
        if ($name != trim($name)) throw new InvalidArgumentException('Invalid parameter $name: "'.$name.'" (enclosing white space)');

        if (strlen($name) && !preg_match('/^[^\s:]+(:[^\s:]+)*$/', $name))
            throw new InvalidArgumentException('Invalid parameter $name: "'.$name.'" (not a command name)');
        return $this;
    }
155449
private ServiceReference checkService(ServiceReference serviceReference, String interfaceClassName)
    {
        if (serviceReference != null)
        {
            Object service = bundleContext.getService(serviceReference);
            if (service != null)
            {
                try {
                    if (interfaceClassName != null)
                        if (!service.getClass().isAssignableFrom(Class.forName(interfaceClassName)))
                            serviceReference = null;
                } catch (ClassNotFoundException e) {
                    // Ignore this error
                }
            }
        }
        return serviceReference;
    }