Class GCNValidator

java.lang.Object
tools.pantheum.gaia.gs1.content.validator.GCNValidator
All Implemented Interfaces:
ContentInterface

public final class GCNValidator extends Object implements ContentInterface
Custom semantic validator for AI 255 — Global Coupon Number (GCN).

The standard pipeline already verifies that:

  • The first 13 characters are digits with a valid modulo-10 check digit.
  • The optional serial suffix (component 2, up to 12 digits) is numeric.

This validator applies the additional semantic rules:

  • The 13-digit GCN key must not be all zeros.
  • The GS1 company prefix — which begins at index 0 of the key (no leading indicator or extension digit) — must match a recognised range in the GS1 prefix registry.

GCN structure

  [ GS1 Company Prefix ][ Coupon Reference ][ Check digit (1) ][ Serial (0–12 digits, optional) ]
  |<-- GS1 prefix check starts at index 0 ---------------------------->||
  • Field Details

    • INSTANCE

      public static final GCNValidator INSTANCE
      The singleton instance.
  • Constructor Details

    • GCNValidator

      public GCNValidator()
      Creates a new GCNValidator.
  • Method Details

    • validate

      public List<GaiaError> validate(GS1AIObjectElement element, GaiaConstants.Language language)
      Description copied from interface: ContentInterface
      Validates the data value of element for semantic correctness and returns the resulting localized errors, or an empty list when valid.
      Specified by:
      validate in interface ContentInterface
      Parameters:
      element - the fully-parsed AI element; never null; GS1AIObjectElement.getValue() is guaranteed non-null and already free of standard errors when this method is called
      language - the language in which to produce the error messages
      Returns:
      one GaiaError per failing condition, in order; empty if valid