Validate a Code Identifier in Java

2 min readOct 2, 2020

Today, we are going to be looking at how to validate code identifiers in Java using a Cloudmersive API. This is particularly useful for developers creating applications and programs for other developers to use. With this API you can determine if an input identifier is valid based on desired input rules including whether whitespace, hyphens, underscores, and other special symbols are allowed. It will also allow you to set a minimum and maximum required length for the identifiers.

Our first step is going to be installing our SDK with Maven. You’ll need to add a reference to the repository in pom.xml:


Then, add a reference to the dependency:


After this, we can add in our imports and run our function, GetDefaultApiClient:

// Import classes:
//import com.cloudmersive.client.invoker.ApiClient;
//import com.cloudmersive.client.invoker.ApiException;
//import com.cloudmersive.client.invoker.Configuration;
//import com.cloudmersive.client.invoker.auth.*;
//import com.cloudmersive.client.NameApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();// Configure API key authorization: Apikey
ApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");
Apikey.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
NameApi apiInstance = new NameApi();
ValidateIdentifierRequest input = new ValidateIdentifierRequest(); // ValidateIdentifierRequest | Identifier validation request information
try {
ValidateIdentifierResponse result = apiInstance.nameIdentifier(input);
} catch (ApiException e) {
System.err.println("Exception when calling NameApi#nameIdentifier");

Now, you can easily determine the validity of any code identifier upon input to decrease stress and frustration for your clients. You can access your free API Key at the Cloudmersive website. This will provide access to 800 monthly calls across our library of APIs.




There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.