Class GRAIValidator
java.lang.Object
tools.pantheum.gaia.gs1.content.validator.GRAIValidator
- All Implemented Interfaces:
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 thezeroformat 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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvalidate(GS1AIObjectElement element, GaiaConstants.Language language) Validates the data value ofelementfor semantic correctness and returns the resulting localized errors, or an empty list when valid.
-
Field Details
-
INSTANCE
The singleton instance.
-
-
Constructor Details
-
GRAIValidator
public GRAIValidator()Creates a newGRAIValidator.
-
-
Method Details
-
validate
Description copied from interface:ContentInterfaceValidates the data value ofelementfor semantic correctness and returns the resulting localized errors, or an empty list when valid.- Specified by:
validatein interfaceContentInterface- Parameters:
element- the fully-parsed AI element; nevernull;GS1AIObjectElement.getValue()is guaranteed non-null and already free of standard errors when this method is calledlanguage- the language in which to produce the error messages- Returns:
- one
GaiaErrorper failing condition, in order; empty if valid
-