Skip to content

Commit

Permalink
Improve integration for international validation (#14)
Browse files Browse the repository at this point in the history
* Improve integration for international validation

---------

Co-authored-by: Patricia Schott <[email protected]>
  • Loading branch information
pschott and Patricia Schott authored Oct 23, 2023
1 parent 8685c44 commit f564eef
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dist/js/experian-address-validation.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/lib/address-search.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ export default class AddressValidation {
private searchSpinner;
private toggleSearchInputs;
private globalReset;
private isInternationalValidation;
}
20 changes: 18 additions & 2 deletions src/ts/address-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,6 @@ export default class AddressValidation {
private search(event: KeyboardEvent): void {
event.preventDefault();

this.currentSearchTerm = this.inputs.map(input => input.value).join(',');

// Grab the country ISO code and (if it is present) the dataset name from the current value of the countryList (format: {countryIsoCode};{dataset})
const currentCountryInfo = this.countryCodeMapping[this.currentCountryCode] || this.currentCountryCode;
const countryCodeAndDataset = currentCountryInfo.split(';');
Expand All @@ -378,6 +376,13 @@ export default class AddressValidation {
this.hasSearchInputBeenReset = true;
}

// Concatenating the input components depending on search type and dataset to maximize match results
if (this.isInternationalValidation()) {
this.currentSearchTerm = this.inputs.map(input => input.value).join('|');
} else {
this.currentSearchTerm = this.inputs.map(input => input.value).join(',');
}

// Check if searching is permitted
if (this.canSearch()) {
// Abort any outstanding requests
Expand Down Expand Up @@ -1417,4 +1422,15 @@ export default class AddressValidation {
// Fire an event after a reset
this.events.trigger('post-reset');
}

private isInternationalValidation(): boolean {
// Return true if the current dataset indicates this is a international data validation call
if (this.searchType === AddressValidationMode.VALIDATE
&& !Array.isArray(this.currentDataSet)
&& this.currentDataSet.toUpperCase().endsWith("-ED")) {
return true;
}

return false;
}
}

0 comments on commit f564eef

Please sign in to comment.