Skip to content

AIDC Toolkit / Utility / RegExpValidator

Class: RegExpValidator

Defined in: reg-exp.ts:13

Regular expression validator. The regular expression applies to the full string only if constructed as such. For example, /\d*/ (0 or more digits) matches every string, /\d+/ (1 or more digits) matches strings with at least one digit, /^\d*$/ matches strings that are all digits or empty, and /^\d+$/ matches strings that are all digits and not empty.

Clients of this class are recommended to override the createErrorMessage method create a more suitable error message for their use case.

Implements

Constructors

Constructor

new RegExpValidator(regExp): RegExpValidator

Defined in: reg-exp.ts:25

Constructor.

Parameters

regExp

RegExp

Regular expression. See class documentation for notes.

Returns

RegExpValidator

Accessors

regExp

Get Signature

get regExp(): RegExp

Defined in: reg-exp.ts:32

Get the regular expression.

Returns

RegExp

Methods

createErrorMessage()

protected createErrorMessage(s): string

Defined in: reg-exp.ts:46

Create an error message for a string. The generic error message is sufficient for many use cases but a more domain-specific error message, possibly including the pattern itself, is often required.

Parameters

s

string

String.

Returns

string

Error message.


validate()

validate(s): void

Defined in: reg-exp.ts:55

Parameters

s

string

Returns

void

Inherit Doc

Implementation of

StringValidator.validate