Home > widget-integration > FilterFormatHelper > isValidPriceHTML
FilterFormatHelper.isValidPriceHTML() method
Validates if HTML contains actual price data (has digits).
Ensures that price HTML contains numeric data before processing. This prevents attempting to format empty or placeholder content. Override this method to implement more sophisticated validation logic, such as checking for specific currency symbols or price format patterns.
Signature:
isValidPriceHTML(html?: string): boolean;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
html |
string |
(Optional) HTML string to validate for price content |
Returns:
boolean
True if HTML contains at least one digit (0-9), false otherwise or if html is undefined
Example 1
Basic usage:
if (helper.isValidPriceHTML('<span>$19.99</span>')) {
// Process price HTML
}
Example 2
Extend to add currency symbol validation:
window.boostWidgetIntegration.extend('FilterFormatHelper', (FilterFormatHelper) => {
return class CustomFilterFormatHelper extends FilterFormatHelper {
isValidPriceHTML(html) {
// Require both digit and currency symbol
if (!html) return false;
const hasDigit = /\d/.test(html);
const hasCurrency = /[$€£¥]/.test(html);
return hasDigit && hasCurrency;
}
};
});