Class GrammleID

Stores the identification of a Mistake and provides methods to parse it, validate it and convert it to different formats.

Hierarchy

  • GrammleID

Constructors

Properties

category: CategoryNames = CategoryNames.g
number: number = 0
ID_REGEX: RegExp = ...

Starts with a letter from CategoryNames and ends with 1-4 digits.

MD5_REGEX: RegExp = ...

Contains 32 hexadecimal characters.

NAME_REGEX: RegExp = ...

Starts with "Grammle-" and then the #ID_REGEX.

ORDER_ID_REGEX: RegExp = ...

Starts with a letter from CategoryNames and ends with 4 digits, but not with 4 zeros.

`(?!0{4})`: Negative lookahead that ensures the number is not 0000 (written by GitHub Copilot)

Methods

  • Checks whether this GrammleID is equal to another GrammleID, based on their string representations generated by toString.

    Returns

    true if the GrammleIDs are equal, false otherwise

    Parameters

    Returns boolean

  • Returns number

  • Sets a new category, but keeps the current number.

    Returns

    true if the category was set successfully

    Parameters

    Returns true

  • Sets a new ID and updates the internal #category and #number accordingly. ID must be in the format <category[0]><UInt>, such as B3 or S10.

    Returns

    true if the ID was set successfully

    Throws

    if the ID is not in the format <category[0]><UInt>

    Parameters

    • id: string

      the new ID

    Returns true | IllegalArgumentError

  • Sets a new ID number, but keeps the current category.

    Returns

    true if the number was set successfully

    Throws

    if the number is not an integer in the range 1-9999

    Parameters

    • number: number

      the new ID number. Must be an integer in the range 1-9999.

    Returns true | IllegalArgumentError

  • Returns this GrammleID in the human-readable format Grammle-<category[0]><number>, such as Grammle-B3 or Grammle-S10.

    Returns

    the GrammleID as a human-readable string

    Returns string

  • Returns a string representation of the GrammleID in the format <first category letter><padding zeros><number>, such as B0003 for Grammle-B3 or S0010 for Grammle-S10.

    Returns

    the orderID as a string

    Returns string

  • Returns a string representation of the GrammleID in the format <mainCategory[0]><number>.

    Returns

    the GrammleID as a string

    Returns string

  • Constructs a new GrammleID from a given order ID. The order ID is the current ID with padding zeros.

    Returns

    the new GrammleID

    Throws

    if the order ID is not in the format <category[0]><padding zeros><UInt> with number.length == 4

    Parameters

    • orderID: string

      the given order ID

    Returns IllegalArgumentError | GrammleID

  • Returns RegExp

  • Returns RegExp

  • Returns RegExp

  • Returns RegExp

  • Checks whether a given ID matches the format <category[0]><number>, but does not check whether a mistake with that ID exists.

    Returns

    true if the ID matches the format, false otherwise

    Parameters

    • id: string

      the ID to check

    Returns boolean

  • Checks whether a given name matches the format Grammle-<category[0]><number>.

    Returns

    true if the name matches the format, false otherwise

    Parameters

    • name: string

      the name to check

    Returns boolean

  • Checks whether a given order ID matches the format <category[0]><padding zeros><number> and whether the number is 4 digits long.

    Returns

    true if the order ID matches the format, false otherwise

    Parameters

    • orderID: string

      the order ID to check

    Returns boolean

  • Checks whether a given String is an MD5 hash, i.e. a 32-character hexadecimal number. Does NOT check whether the MD5 hash already exists in the MistakeManager.

    Returns

    true if the String is an MD5 hash, false otherwise

    Parameters

    • uid: string

      the String to check

    Returns boolean

Generated using TypeDoc