AIDC Toolkit / GS1 / AbstractIdentifierValidator
Abstract Class: AbstractIdentifierValidator<TIdentifierValidation>
Defined in: src/identifier-validator.ts:99
Abstract identifier validator. Implements common functionality for an identifier validator.
Extended by
Type Parameters
TIdentifierValidation
TIdentifierValidation extends IdentifierValidation = IdentifierValidation
Implements
IdentifierValidator<TIdentifierValidation>
Constructors
Constructor
protectednew AbstractIdentifierValidator<TIdentifierValidation>(identifierType,prefixType,length,referenceCharacterSet):AbstractIdentifierValidator<TIdentifierValidation>
Defined in: src/identifier-validator.ts:159
Constructor.
Parameters
identifierType
Identifier type.
prefixType
Prefix type.
length
number
Length.
referenceCharacterSet
Reference character set.
Returns
AbstractIdentifierValidator<TIdentifierValidation>
Accessors
identifierType
Get Signature
get identifierType():
IdentifierType
Defined in: src/identifier-validator.ts:170
Get the identifier type. Per the GS1 General Specifications, the identifier type determines the remaining properties.
Returns
Implementation of
IdentifierValidator.identifierType
prefixType
Get Signature
get prefixType():
PrefixType
Defined in: src/identifier-validator.ts:177
Get the prefix type supported by the identifier type. For all identifier types except the GTIN, this is PrefixTypes.GS1CompanyPrefix. For the GTIN, the prefix type determines the length.
Returns
Implementation of
IdentifierValidator.prefixType
length
Get Signature
get length():
number
Defined in: src/identifier-validator.ts:184
Get the length. For numeric identifier types, the length is fixed; for alphanumeric identifier types, the length is the maximum.
Returns
number
Implementation of
referenceCharacterSet
Get Signature
get referenceCharacterSet():
ContentCharacterSet
Defined in: src/identifier-validator.ts:191
Get the reference character set.
Returns
Implementation of
IdentifierValidator.referenceCharacterSet
referenceCreator
Get Signature
get referenceCreator():
CharacterSetCreator
Defined in: src/identifier-validator.ts:198
Get the reference creator.
Returns
Implementation of
IdentifierValidator.referenceCreator
Methods
creatorFor()
protectedstaticcreatorFor(characterSet):CharacterSetCreator
Defined in: src/identifier-validator.ts:140
Get the character set creator for a character set.
Parameters
characterSet
Character set.
Returns
Character set creator.
padIdentifier()
protectedpadIdentifier(identifier,validation):string
Defined in: src/identifier-validator.ts:215
Pad an identifier on the left with zero-value character for validation purposes. This is done to align an identifier with a position offset for any error message that may be thrown by the reference validator.
Parameters
identifier
string
Identifier.
validation
Identifier validation parameters.
IdentifierValidation | undefined
Returns
string
Padded identifier.
validatePrefix()
protectedvalidatePrefix(partialIdentifier,positionOffset?):void
Defined in: src/identifier-validator.ts:229
Validate the prefix within an identifier.
Parameters
partialIdentifier
string
Partial identifier.
positionOffset?
number
Position offset within a larger string.
Returns
void
validate()
abstractvalidate(identifier,validation?):void
Defined in: src/identifier-validator.ts:234
Validate an identifier and throw an error if validation fails.
Parameters
identifier
string
Identifier.
validation?
TIdentifierValidation
Identifier validation parameters.
Returns
void