Skip to content

AIDC Toolkit / Utility / CharacterSetValidator

Class: CharacterSetValidator

Defined in: character-set.ts:44

Character set validator. Validates a string against a specified character set.

Extended by

Implements

Constructors

Constructor

new CharacterSetValidator(characterSet, ...exclusionSupport): CharacterSetValidator

Defined in: character-set.ts:86

Constructor.

Parameters

characterSet

readonly string[]

Character set. Each element is a single-character string, unique within the array, that defines the character set.

exclusionSupport

...readonly Exclusion[]

Exclusions supported by the character set. All character sets implicitly support Exclusions.None.

Returns

CharacterSetValidator

Accessors

characterSet

Get Signature

get characterSet(): readonly string[]

Defined in: character-set.ts:103

Get the character set.

Returns

readonly string[]


characterSetSize

Get Signature

get characterSetSize(): number

Defined in: character-set.ts:110

Get the character set size.

Returns

number


exclusionSupport

Get Signature

get exclusionSupport(): readonly Exclusion[]

Defined in: character-set.ts:117

Get the exclusions supported by the character set.

Returns

readonly Exclusion[]

Methods

character()

character(index): string

Defined in: character-set.ts:130

Get the character at an index.

Parameters

index

number

Index into the character set.

Returns

string

Character at the index.


characterIndex()

characterIndex(c): number | undefined

Defined in: character-set.ts:143

Get the index for a character.

Parameters

c

string

Character.

Returns

number | undefined

Index for the character or undefined if the character is not in the character set.


characterIndexes()

characterIndexes(s): readonly (number | undefined)[]

Defined in: character-set.ts:156

Get the indexes for all characters in a string.

Parameters

s

string

String.

Returns

readonly (number | undefined)[]

Array of indexes for each character or undefined if the character is not in the character set.


validateExclusion()

protected validateExclusion(exclusion): void

Defined in: character-set.ts:180

Validate that an exclusion is supported. If not, an error is thrown.

Parameters

exclusion

Exclusion

Exclusion.

Returns

void


validate()

validate(s, validation?): void

Defined in: character-set.ts:198

Validate a string. If the string violates the character set or any of the character set validation parameters, an error is thrown.

Parameters

s

string

String.

validation?

CharacterSetValidation

Character set validation parameters.

Returns

void

Implementation of

StringValidator.validate