RegExpValidator
Class: RegExpValidator
Defined in: packages/utils/src/regexp.ts:5
A utility class that validates strings against one or more regular expressions,
automatically anchoring each pattern with ^ and $ if not already present.
Extended by
Constructors
Constructor
new RegExpValidator(
info):RegExpValidator
Defined in: packages/utils/src/regexp.ts:11
Parameters
info
string | string[]
One or more regex pattern strings to validate against.
Returns
RegExpValidator
Properties
validators
protectedvalidators:RegExp[]
Defined in: packages/utils/src/regexp.ts:6
Methods
validate()
validate(
value):boolean
Defined in: packages/utils/src/regexp.ts:38
Test whether a value matches at least one of the registered patterns.
Parameters
value
string
The string to validate.
Returns
boolean
true if the value matches any pattern; otherwise false.
getRegExp()
staticgetRegExp(reg):RegExp
Defined in: packages/utils/src/regexp.ts:22
Normalize a regex pattern string by ensuring it is anchored with ^ and $.
Parameters
reg
string
The regex pattern string to normalize.
Returns
RegExp
A RegExp anchored at both start and end.