Class GRAIValidator

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

public final class GRAIValidator extends Object implements ContentInterface
Custom semantic validator for AI 8003 — Global Returnable Asset Identifier (GRAI).

The standard pipeline already verifies:

  • Component 0 (N1): must be "0" — validated by the zero format validator.
  • Component 1 (N13): digits only, with a valid modulo-10 check digit.
  • Component 2 (X..16): optional serial — GS1 AI encodable characters only.

This validator applies the additional semantic rules:

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

GRAI structure

  [ "0" (1 digit) ][ GS1 Company Prefix ][ Asset Type ][ Check digit (1) ][ Serial (0–16, optional) ]
  Component 0        Component 1 — GS1 prefix check starts at index 0      Component 2
  • Field Details

    • INSTANCE

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

    • GRAIValidator

      public GRAIValidator()
      Creates a new GRAIValidator.
  • 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