Interface CdigitAlgo

The common interface for check digit algorithm implementations.

Hierarchy

  • CdigitAlgo

Properties

longName: string

A human-readable name of the algorithm.

name: string

The cdigit name of the algorithm.

Methods

  • Generates the check characters from the argument using the algorithm. Unlike generate(), this method returns the check characters only.

    Returns

    The check characters.

    Throws

    SyntaxError if an algorithm-specific syntax error occurs. Note that the bundled algorithm objects do not generally throw errors because they ignore the unknown letters in the string to be protected.

    Parameters

    • strWithoutCheckChars: string

      A string without check characters.

    Returns string

  • Generates the check characters from the argument using the algorithm. This method is an alphabet-independent equivalent of compute(), where the return value and argument are both represented as arrays of each digit's numerical value.

    Returns

    The check characters decoded to an array of numerical values.

    Throws

    SyntaxError if the argument contains an invalid numerical value or any other algorithm-specific syntax error occurs.

    Parameters

    • numValsWithoutCheckChars: number[]

      A string without check characters decoded to an array of numerical values.

    Returns number[]

  • Generates the protected string from the argument using the algorithm. The generated string consists of the original bare string and computed check characters, which are combined in accordance with the algorithm.

    Returns

    The string with check characters.

    Throws

    SyntaxError if an algorithm-specific syntax error occurs. Note that the bundled algorithm objects do not generally throw errors because they ignore the unknown letters in the string to be protected.

    Parameters

    • strWithoutCheckChars: string

      A string without check characters.

    Returns string

  • Splits a protected string into the pair of original bare string and check characters.

    Returns

    The tuple of [string without check characters, check characters].

    Throws

    SyntaxError if the argument does not contain check characters or any other algorithm-specific syntax error occurs. Note that the bundled algorithm objects do not generally throw errors because they ignore the unknown letters in the string to be protected.

    Parameters

    • strWithCheckChars: string

      A string with check characters.

    Returns [string, string]

  • Checks if a protected string is valid per the algorithm.

    Returns

    True if the argument is valid.

    Throws

    SyntaxError if the argument does not contain check characters or any other algorithm-specific syntax error occurs. Note that the bundled algorithm objects do not generally throw errors because they ignore the unknown letters in the string to be protected.

    Parameters

    • strWithCheckChars: string

      A string with check characters.

    Returns boolean

Generated using TypeDoc