Home > widget-integration > FilterValidationHelper > normalizeWhitespace

FilterValidationHelper.normalizeWhitespace() method

Trims and normalizes whitespace in a string.

Removes leading/trailing whitespace and replaces multiple spaces with single space.

Signature:

normalizeWhitespace(value: string): string;

Parameters

Parameter

Type

Description

value

string

The string to normalize. Can contain any amount of whitespace.

Returns:

string

Normalized string with single spaces and no leading/trailing whitespace

Example

Normalize user input:

const cleaned = this.validationHelper.normalizeWhitespace(userInput);
// 'hello    world  ' becomes 'hello world'