Skip to content

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

Constructors

Constructor

protected new AbstractIdentifierValidator<TIdentifierValidation>(identifierType, prefixType, length, referenceCharacterSet): AbstractIdentifierValidator<TIdentifierValidation>

Defined in: src/identifier-validator.ts:159

Constructor.

Parameters

identifierType

IdentifierType

Identifier type.

prefixType

PrefixType

Prefix type.

length

number

Length.

referenceCharacterSet

ContentCharacterSet

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

IdentifierType

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

PrefixType

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

IdentifierValidator.length


referenceCharacterSet

Get Signature

get referenceCharacterSet(): ContentCharacterSet

Defined in: src/identifier-validator.ts:191

Get the reference character set.

Returns

ContentCharacterSet

Implementation of

IdentifierValidator.referenceCharacterSet


referenceCreator

Get Signature

get referenceCreator(): CharacterSetCreator

Defined in: src/identifier-validator.ts:198

Get the reference creator.

Returns

CharacterSetCreator

Implementation of

IdentifierValidator.referenceCreator

Methods

creatorFor()

protected static creatorFor(characterSet): CharacterSetCreator

Defined in: src/identifier-validator.ts:140

Get the character set creator for a character set.

Parameters

characterSet

ContentCharacterSet

Character set.

Returns

CharacterSetCreator

Character set creator.


padIdentifier()

protected padIdentifier(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()

protected validatePrefix(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()

abstract validate(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

Implementation of

IdentifierValidator.validate