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
- AddressValidationInput_V1
- AddressValidationOutput_V1
- EmailValidationInput_V1
- EmailValidationOutput_v1
- EmailSuggestInput_V1
- EmailSuggestOutput_V1
- PhoneValidationInput_V1
- PhoneValidationOutput_V1
- rv2SaveValidationResultInput_v1
- rv2SaveValidationResultOutput_v1
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: AddressValidationInput_V1
Return Value
Type: AddressValidationOutput_V1
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: EmailValidationInput_V1
Return Value
Type: EmailValidationOutput_V1
Example
recordval.RecordValidationAPI_v1 api = new recordval.RecordValidationAPI_v1();
recordval.EmailValidationInput_v1 input = new recordval.EmailValidationInput_v1();
input.emailAddress = '[email protected]';
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: EmailSuggestInput_V1
Return Value
Type: EmailSuggestOutput_V1
Example
recordval.RecordValidationAPI_v1 api = new recordval.RecordValidationAPI_v1();
recordval.EmailSuggestInput_v1 input = new recordval.EmailSuggestInput_v1();
input.emailAddress = '[email protected]';
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: PhoneValidationInput_V1
Return Value
Type: PhoneValidationOutput_V1
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: rv2SaveValidationResultInput_v1
Return Value
Type: rv2SaveValidationResultOutput_v1
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);
AddressValidationinput_V1
| 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 | AddressOptions_v1 |
AddressOptions_v1
| 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 |
AddressValidationOutput_V1
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 | Status_v1 | ||
| advice | Enum Advice_v1 |
Advice_v1
| Field | Type | Mandatory | Description |
| advice | string | Enum: Green, Amber, Red |
Status_v1
| Field | Type | Mandatory | Description |
| code | string | ||
| message | string | ||
| credit | boolean |
AddressSuggestInput_v1
| 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 |
AddressSuggestOutput_v1
| Field | Type | Mandatory | Description |
| suggestions | string | ||
| status | Status_v1 |
Status_V1
| Field | Type | Mandatory | Description |
| code | string | ||
| message | string | ||
| credit | boolean |
AddressCompleteInput_v1
| 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 |
AddressOptions_v1
| 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 |
AddressCompleteOutput_v1
| Field | Type | Mandatory | Description |
| address | Address_v1 |
Address_v1
| Field | Type | Mandatory | Description |
| street | string | ||
| housenumber | string | ||
| housenumberAddition | string | ||
| state | string | ||
| city | string | ||
| postalCode | string | ||
| country | string | ||
| countryCode | string | ||
| fullAddress | string | ||
| status | Status_v1 | ||
| advice | Advice_v1 |
Status_v1
| Field | Type | Mandatory | Description |
| code | string | ||
| message | string | ||
| credit | boolean |
Advice_v1
| Field | Type | Mandatory | Description |
| advice | string | Enum: Green, Amber, Red |
EmailValidationInput_v1
| Field | Type | Mandatory | Description |
| emailAddress | string | Yes | The input email address |
| note | string | This message is included in the transaction logging |
EmailValidationOutput_v1
| 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 | Status_v1 | ||
| advice | Advice_v1 |
Status_v1
| Field | Type | Mandatory | Description |
| code | string | ||
| message | string | ||
| credit | boolean |
Advice_v1
| Field | Type | Mandatory | Description |
| advice | string | Enum: Green, Amber, Red |
EmailSuggestInput_v1
| 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 |
EmailSuggestOutput_v1
| Field | Type | Mandatory | Description |
| suggestions | string | ||
| status | Status_v1 |
Status_v1
| Field | Type | Mandatory | Description |
| code | string | ||
| message | string | ||
| credit | boolean |
PhoneValidationInput_v1
| Field | Type | Mandatory | Description |
| phoneNumber | string | Yes | |
| country | string | ||
| note | string | This message is included in the transaction logging | |
| Yes | Format_v1 | Yes |
Format_v1
| Field | Type | Mandatory | Description |
| PhoneFormat | string | Yes | Enum: E164, INTERNATIONAL, NATIONAL, RFC3966 |
PhoneValidationOutput_v1
| Field | Type | Mandatory | Description |
| phoneNumber | string | The Correctly formatted and standardized phone number | |
| status | Status_v1 | ||
| advice | Advice_v1 |
Status_v1
| Field | Type | Mandatory | Description |
| code | string | ||
| message | string | ||
| credit | boolean |
Advice_v1
| Field | Type | Mandatory | Description |
| advice | string | Enum: Green, Amber, Red |
rv2SaveValidationResultInput_v1
| 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. AddressValidationOutput_v1, EmailValidationOutput_v1, PhoneValidationOutput_v1 |
rvSaveValidationResultOutput_v1
| 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 |