@sb1/ffe-account-selector-react
Version:
Selector for bank accounts with autocomplete.
18 lines (17 loc) • 756 B
JavaScript
/**
* This matcher function closely resembles the default one of SearchableDropdown,
* but it ignores all spaces and periods so that account number formatting won't mess with the search.
*/
export var searchMatcherIgnoringAccountNumberFormatting = function (searchString, searchAttributes) {
return function (item) {
var cleanString = function (value) {
return "".concat(value)
.replace(/(\s|\.)/g, '') // Remove all spaces and periods
.toLowerCase();
};
var cleanedSearchString = cleanString(searchString);
return searchAttributes.some(function (searchAttribute) {
return cleanString(item[searchAttribute]).includes(cleanedSearchString);
});
};
};