Skip to main content
cngx-src documentation

patternMatch

Functionforms/validators

projects/forms/validators/pattern-match.validator.ts

Description#

Validates that the string control value matches the given regular expression. Returns null when valid, { patternMatch: { pattern, actual } } otherwise.

Returns null (valid) when the control value is empty or falsy — pair with Validators.required when an empty value is not acceptable.

Signature#

patternMatch(pattern: RegExp)

Parameters#

@parampatternRegExp

Returns#

ValidatorFn