Home > widget-integration > FilterValidationHelper > matchesPattern

FilterValidationHelper.matchesPattern() method

Validates if a string matches a specific pattern.

Uses custom regex pattern for flexible validation rules.

Signature:

matchesPattern(value: string, pattern: RegExp): boolean;

Parameters

Parameter

Type

Description

value

string

The value to validate against the pattern

pattern

RegExp

The regex pattern to match against

Returns:

boolean

true if the value matches the pattern, false otherwise

Example

Validate custom format:

const phonePattern = /^\d{3}-\d{3}-\d{4}$/;
if (this.validationHelper.matchesPattern(phone, phonePattern)) {
  this.savePhoneNumber(phone);
}