Name Validation

Last updated: September 14th, 2018

OVERVIEW

This API validates names of people in "FirstName LastName" format.

REQUEST & RESPONSE

The API uses GET method to send request. Below you can find sample synax.

Request Method:

GET https://apineo.app/name-validation?name=Firstname Lastname

Response "VALID"

Below you can find a "valid" response sample.

Sample Request:

GET https://apineo.app/name-validation?name=John Doe

Result:
{
    "success": true,
    "result": "valid",
    "name": "YOUR NAME",
    "execution_time_spent": 0.0001060962677002
}

Response "INVALID"

Below you can find an "invalid" response sample.

Sample Bad Request:

GET https://apineo.app/name-validation?name=John

Result:
{
    "success": true,
    "result": "invalid",
    "name": "YOUR",
    "info": "Only valid names are allowed.",
    "valid_syntax_example": "https://apineo.app/name-validation/?name=Ion Vasilevschi",
    "execution_time_spent": 4.6014785766602e-5
}

Response "ERROR"

Below you can find an "error" response.

Sample Bad Request:

GET https://apineo.app/name-validation?nam

Result:
{
    "success": false,
    "error": "Error. You must provide a name.",
    "valid_syntax_example": "https://apineo.app/name-validation/?name=Ion Vasilevschi",
    "execution_time_spent": 0.00013113021850586
}

SAMPLE CODES

Below you can find a usage sample php code using cURL.

PHP Code Example
<?php 
//Validation function using cURL
function validate_name($name){
	$ch = curl_init("https://apineo.app/name-validation/?name=".urlencode($name)."");  
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	$json = curl_exec($ch);
	curl_close($ch);
	$validationResult = json_decode($json, true);
	if($validationResult["result"]=="valid"){
		return true;
	}else{
		return false;
	}
	
} 

//USAGE
if(validate_name("Firstname Lastname")){
	//do success code ...
}else{
	//do error code ...
}
?>