Class GTINValidator

GTIN validator.

Hierarchy

  • AbstractNumericIdentificationKeyValidator
    • GTINValidator

Constructors

Accessors

  • get length(): number
  • Returns number

Methods

  • Zero suppress a GTIN-12.

    Parameters

    • gtin12: string

      GTIN-12.

    Returns string

    Zero-suppressed GTIN-12.

  • Zero expand a zero-suppressed GTIN-12.

    Parameters

    • zeroSuppressedGTIN12: string

      Zero-suppressed GTIN-12.

    Returns string

    GTIN-12.

  • Convert a GTIN of any length to a GTIN-14 with an optional indicator digit.

    Parameters

    • indicatorDigit: string

      Indicator digit. If blank, assumes "0" if the GTIN is not already a GTIN-14.

    • gtin: string

      GTIN.

    Returns string

    GTIN-14.

  • Normalize a GTIN of any length.

    • A GTIN-14 that starts with six zeros or a GTIN-13 that starts with five zeros is normalized to GTIN-8.
    • A GTIN-14 that starts with two zeros or a GTIN-13 that starts with one zero is normalized to GTIN-12.
    • A GTIN-14 that starts with one zero is normalized to GTIN-13.
    • Otherwise, the GTIN is unchanged.

    Parameters

    • gtin: string

      GTIN.

    Returns string

    Normalized GTIN.

  • Validate any GTIN, optionally against a level.

    Parameters

    • gtin: string

      GTIN.

    • gtinLevel: GTINLevel = GTINLevel.Any

      Level at which GTIN is to be validated.

    Returns void

  • Validate a GTIN-14.

    Parameters

    • gtin14: string

      GTIN-14.

    Returns void

  • Parameters

    • partialIdentificationKey: string
    • OptionalpositionOffset: number

    Returns void

  • Pad an identification key on the left with zero-value character for validation purposes. This is done to align an identification key with a position offset for any error message that may be thrown by the reference validator.

    Parameters

    • identificationKey: string

      Identification key.

    • validation: undefined | IdentificationKeyValidation

      Identification key validation parameters.

    Returns string

    Padded identification key.