Validate a Full Name in Go
Accepting user input via online forms is an easy and approachable way to gather information in your websites and applications. The flip side however, is that the data is subject to human error and may be invalid. To assist in preparing your system for this eventuality, the following API will validate a full name string and return all applicable fields including the title, first name, middle name, last name, nickname, suffix, and display name of a user.
All you will need to call the function in Go is the full name string and your API key, which you can input into the below example code:
package mainimport (
"fmt"
"strings"
"net/http"
"io/ioutil"
)func main() {url := "https://api.cloudmersive.com/validate/name/full-name"
method := "POST"payload := strings.NewReader(`{
"FullNameString": "<string>"
}`)client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Apikey", "YOUR-API-KEY-HERE")res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
You will receive the aforementioned results in seconds flat. If you need to obtain an API key, head to the Cloudmersive website to register for a free account: this provides access to 800 monthly calls across any of our APIs.