Class CharacterSetValidator

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

Hierarchy (view full)

Implements

Constructors

  • Constructor.

    Parameters

    • characterSet: readonly string[]

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

    • Rest...exclusionSupport: readonly Exclusion[]

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

    Returns CharacterSetValidator

Accessors

  • get characterSet(): readonly string[]
  • Get the character set.

    Returns readonly string[]

  • get characterSetSize(): number
  • Get the character set size.

    Returns number

Methods

  • Get the character at an index.

    Parameters

    • index: number

      Index into the character set.

    Returns string

    Character at the index.

  • Get the index for a character.

    Parameters

    • c: string

      Character.

    Returns undefined | number

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

  • Get the indexes for all characters in a string.

    Parameters

    • s: string

      String.

    Returns readonly (undefined | number)[]

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

  • Validate that an exclusion is supported. If not, an exception is thrown.

    Parameters

    Returns void

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

    Parameters

    Returns void