Class GCNValidator
java.lang.Object
tools.pantheum.gaia.gs1.content.validator.GCNValidator
- All Implemented Interfaces:
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 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
-
GCNValidator
public GCNValidator()Creates a newGCNValidator.
-
-
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
-