Home > widget-integration > FilterValidationHelper > isValidUrl

FilterValidationHelper.isValidUrl() method

Validates if a string is a valid URL.

Uses the URL constructor for validation, which checks protocol, host, and format.

Signature:

isValidUrl(url: string): boolean;

Parameters

Parameter

Type

Description

url

string

The URL string to validate. Should include protocol (http://, https://).

Returns:

boolean

true if the string is a valid, parseable URL, false otherwise

Example

Validate user-provided URL:

if (this.validationHelper.isValidUrl(imageUrl)) {
  this.loadImage(imageUrl);
}