Record Validation Apex API
Use the Apex API code for Record Validation in your own customizations within Salesforce. Find all Apex API details below.
Methods
The following methods are available in the Record Validation Apex API:
- validateAddress(addressInput)
Lets you validate an address. - validateEmail(emailInput)
Lets you validate an email address. - suggestEmail(emailInput)
Lets you suggest an email address based on partial input. - validatePhone(phoneInput)
Lets you validate phone numbers. - saveValidationResult(rv2SaveValidationResultInputv1)
Lets you save the validation result to a record.
Models
- AddressValidationInputV1
- AddressValidationOutputV1
- EmailValidationInputV1
- EmailValidationOutputv1
- EmailSuggestInputV1
- EmailSuggestOutputV1
- PhoneValidationInputV1
- PhoneValidationOutputV1
- rv2SaveValidationResultInputv1
- rv2SaveValidationResultOutputv1
Status Codes
- Address Validation Status codes
- Geocode Status Codes
- Email Validation Status codes
- Phone Validation Status codes
validateAddress(addressInput)
Lets you validate an address.
Signature
global AddressValidationOutput\_v1 validateAddress(AddressValidationInput\_V1 addressInput)
Parameters
addressInput - Type: AddressValidationInputV1
Return Value
Type: AddressValidationOutputV1
Example
recordval.RecordValidationAPI\_v1 api = new recordval.RecordValidationAPI\_v1();
recordval.AddressValidationInput\_v1 input = new recordval.AddressValidationInput\_v1();
input.street = 'Velperweg 8';
input.country = 'NL';
input.note = 'demo';
recordval.AddressValidationOutput\_v1 output = api.validateAddress(input);
System.debug(LoggingLevel.DEBUG, output.advice);
System.debug(LoggingLevel.DEBUG, output.addresses.get(0).advice);
validateEmail(emailInput)
Signature
global EmailValidationOutput\_v1 validateEmail(EmailValidationInput\_V1 emailInput)
Parameters
validateEmail - Type: EmailValidationInputV1
Return Value
Type: EmailValidationOutputV1
Example
recordval.RecordValidationAPI\_v1 api = new recordval.RecordValidationAPI\_v1();
recordval.EmailValidationInput\_v1 input = new recordval.EmailValidationInput\_v1();
input.emailAddress = 'demo@plauti.com';
input.note = 'demo';
recordval.EmailValidationOutput\_v1 output = api.validateEmail(input);
System.debug(LoggingLevel.DEBUG, output.advice);
System.debug(LoggingLevel.DEBUG, output.status);
suggestEmail(emailInput)
Signature
global EmailSuggestOutput\_v1 suggestEmail(EmailSuggestInput\_V1 emailInput)
Parameters
suggestEmail - Type: EmailSuggestInputV1
Return Value
Type: EmailSuggestOutputV1
Example
recordval.RecordValidationAPI\_v1 api = new recordval.RecordValidationAPI\_v1();
recordval.EmailSuggestInput\_v1 input = new recordval.EmailSuggestInput\_v1();
input.emailAddress = 'demo@plauti.com';
input.note = 'demo';
recordval.EmailSuggestOutput\_v1 output = api.suggestEmail(input);
System.debug(LoggingLevel.DEBUG, output.suggestions.get(0));
System.debug(LoggingLevel.DEBUG, output.status);
validatePhone(phoneInput)
Signature
global PhoneValidationOutput\_v1 validatePhone(PhoneValidationInput\_V1 phoneInput)
Parameters
validatePhone - Type: PhoneValidationInputV1
Return Value
Type: PhoneValidationOutputV1
Example
recordval.RecordValidationAPI\_v1 api = new recordval.RecordValidationAPI\_v1();
recordval.PhoneValidationInput\_v1 input = new recordval.PhoneValidationInput\_v1();
input.phoneNumber = '0031-345677733';
input.country = 'NL';
input.format = PhoneFormat\_v1.INTERNATIONAL;
input.note = 'demo';
recordval.PhoneValidationOutput\_v1 output = api.validatePhone(input);
System.debug(LoggingLevel.DEBUG, output.advice);
System.debug(LoggingLevel.DEBUG, output.status);
System.debug(LoggingLevel.DEBUG, output.phoneNumber);
saveValidationResult(rv2SaveValidationResultInputv1)
Signature
global rv2SaveValidationResultOutput\_v1 saveValidationResult(
rv2SaveValidationResultInput\_v1 saveValidationRequest
)
Parameters
saveValidationRequest - Type: rv2SaveValidationResultInputv1
Return Value
Type: rv2SaveValidationResultOutputv1
Example
// Create a new rv2SaveResultsInputObject
recordval.rv2SaveValidationResultInput\_v1 saveResults = new recordval.rv2SaveValidationResultInput\_v1();
// Set the recordId in which the result needs to be stored
saveResults.setRecordId(recordId);
// Pass the fieldName that needs to be validated and the result from the validation
saveResults.setValidationResult(fieldName, output);
recordval.rv2SaveValidationResultOutput\_v1 result = api.saveValidationResult(saveResults);
System.debug(LoggingLevel.debug, result.recordId);
System.debug(LoggingLevel.debug, result.success);
AddressValidationinputV1
| Field | Type | Mandatory | Description |
| street | String | Yes | |
| housenumber | String | ||
| housenumberAddition | String | ||
| state | String | ||
| city | String | ||
| postalcode | String | ||
| country | String | Yes | |
| note | String | This message is included in the transaction logging | |
| addressOptions | AddressOptionsv1 |
AddressOptionsv1
| Field | Type | Mandatory | Description |
| housenumber | Boolean | When you want to get the result of the validation with the house number addition not in the house number field. default: false |
|
| housenumberAddition | Boolean | When you want to get the result of the validation with the house number not in the street field. default: false |
AddressValidationOutputV1
Addresses
| Field | Type | Mandatory | Description |
| street | string | Yes | |
| housenumber | string | ||
| housenumberAddition | string | ||
| state | string | ||
| city | string | ||
| postalCode | string | ||
| country | string | Yes | |
| countryCode | string | ||
| fullAddress | string | ||
| status | Statusv1 | ||
| advice | Enum Advicev1 |
Advicev1
| Field | Type | Mandatory | Description |
| advice | string | Enum: Green, Amber, Red |
Statusv1
| Field | Type | Mandatory | Description |
| code | string | ||
| message | string | ||
| credit | boolean |
AddressSuggestInputv1
| Field | Type | Mandatory | Description |
| address | string | Yes | The partial input for the address search |
| country | string | The country for which the address search should be done | |
| index | integer | ||
| note | string | This message is included in the transaction logging |
AddressSuggestOutputv1
| Field | Type | Mandatory | Description |
| suggestions | string | ||
| status | Statusv1 |
StatusV1
| Field | Type | Mandatory | Description |
| code | string | ||
| message | string | ||
| credit | boolean |
AddressCompleteInputv1
| Field | Type | Mandatory | Description |
| address | string | Yes | The partial input for the address search |
| country | string | The country for which the address search should be done. (fallback to RV Setup Settings) | |
| index | integer | Yes | The list index items of the address selected. Starting with 0 |
| note | string | This message is included in the transaction logging |
AddressOptionsv1
| Field | Type | Mandatory | Description |
| housenumberAddition | boolean | When you want to get the result of the validation with the house number addition not in the house number field. default: false |
|
| houseNumber | boolean | When you want to get the result of the validation with the house number not in the street field. default: false |
AddressCompleteOutputv1
| Field | Type | Mandatory | Description |
| address | Addressv1 |
Addressv1
| Field | Type | Mandatory | Description |
| street | string | ||
| housenumber | string | ||
| housenumberAddition | string | ||
| state | string | ||
| city | string | ||
| postalCode | string | ||
| country | string | ||
| countryCode | string | ||
| fullAddress | string | ||
| status | Statusv1 | ||
| advice | Advicev1 |
Statusv1
| Field | Type | Mandatory | Description |
| code | string | ||
| message | string | ||
| credit | boolean |
Advicev1
| Field | Type | Mandatory | Description |
| advice | string | Enum: Green, Amber, Red |
EmailValidationInputv1
| Field | Type | Mandatory | Description |
| emailAddress | string | Yes | The input email address |
| note | string | This message is included in the transaction logging |
EmailValidationOutputv1
| Field | Type | Mandatory | Description |
| complete | string | the complete email address | |
| addressee | string | the addressee part before the @ | |
| domain | string | the domain part after the @ | |
| free | boolean | is a free email address like gmail.com or yahoo.com | |
| disposable | boolean | is a disposable email address. Like mailinator | |
| status | Statusv1 | ||
| advice | Advicev1 |
Statusv1
| Field | Type | Mandatory | Description |
| code | string | ||
| message | string | ||
| credit | boolean |
Advicev1
| Field | Type | Mandatory | Description |
| advice | string | Enum: Green, Amber, Red |
EmailSuggestInputv1
| Field | Type | Mandatory | Description |
| emailAddress | string | Yes | the Input email address. Could be partial like 'user@gm' |
| note | string | This message is included in the transaction logging |
EmailSuggestOutputv1
| Field | Type | Mandatory | Description |
| suggestions | string | ||
| status | Statusv1 |
Statusv1
| Field | Type | Mandatory | Description |
| code | string | ||
| message | string | ||
| credit | boolean |
PhoneValidationInputv1
| Field | Type | Mandatory | Description |
| phoneNumber | string | Yes | |
| country | string | ||
| note | string | This message is included in the transaction logging | |
| Yes | Formatv1 | Yes |
Formatv1
| Field | Type | Mandatory | Description |
| PhoneFormat | string | Yes | Enum: E164, INTERNATIONAL, NATIONAL, RFC3966 |
PhoneValidationOutputv1
| Field | Type | Mandatory | Description |
| phoneNumber | string | The Correctly formatted and standardized phone number | |
| status | Statusv1 | ||
| advice | Advicev1 |
Statusv1
| Field | Type | Mandatory | Description |
| code | string | ||
| message | string | ||
| credit | boolean |
Advicev1
| Field | Type | Mandatory | Description |
| advice | string | Enum: Green, Amber, Red |
rv2SaveValidationResultInputv1
| Field | Type | Mandatory | Description |
| setRecordId | ID | Yes | Sets the recordID where the validation result should be saved |
| setValidationResult | String | Yes | Consists of: fieldName, output |
| fieldName | String | Yes | The name of the field that the output came from, e.g. street, emailAddress, phoneNumber |
| output | Method output | Yes | The validation output, e.g. AddressValidationOutputv1, EmailValidationOutputv1, PhoneValidationOutputv1 |
rvSaveValidationResultOutputv1
| Field | Type | Description |
| recordId | ID | ID of the record where the validation results were saved |
| success | Boolean | Returns "True" when the save was successful, "False" when it failed |