@aidc-toolkit/gs1 1.0.23-beta → 1.0.24-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +4624 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1588 -0
- package/dist/index.d.ts +1588 -36
- package/dist/index.js +4541 -19
- package/dist/index.js.map +1 -1
- package/package.json +4 -8
- package/src/character-set.ts +16 -1
- package/src/check.ts +2 -2
- package/src/gtin-creator.ts +4 -4
- package/src/gtin-validator.ts +6 -6
- package/src/identifier-creator.ts +3 -3
- package/src/identifier-validator.ts +4 -4
- package/src/index.ts +19 -19
- package/src/locale/i18n.ts +3 -5
- package/src/locale/i18next.d.ts +1 -1
- package/src/non-gtin-numeric-identifier-creator.ts +4 -4
- package/src/non-gtin-numeric-identifier-validator.ts +3 -3
- package/src/non-numeric-identifier-creator.ts +6 -6
- package/src/non-numeric-identifier-validator.ts +6 -6
- package/src/numeric-identifier-creator.ts +3 -3
- package/src/numeric-identifier-validator.ts +5 -5
- package/src/prefix-manager.ts +16 -16
- package/src/prefix-provider.ts +1 -1
- package/src/prefix-validator.ts +2 -2
- package/src/serializable-numeric-identifier-creator.ts +4 -4
- package/src/serializable-numeric-identifier-validator.ts +5 -5
- package/test/creator.test.ts +3 -3
- package/test/gtin-creator.ts +1 -1
- package/test/gtin-validator.test.ts +1 -1
- package/test/identifier-creator.ts +4 -4
- package/test/non-gtin-numeric-identifier-creator.ts +1 -1
- package/test/non-gtin-numeric-identifier-validator.ts +1 -1
- package/test/non-numeric-identifier-validator.ts +2 -2
- package/test/numeric-identifier-creator.ts +1 -1
- package/test/numeric-identifier-validator.ts +1 -1
- package/test/prefix-manager.test.ts +1 -1
- package/test/serializable-numeric-identifier-creator.ts +1 -1
- package/test/serializable-numeric-identifier-validator.ts +2 -2
- package/test/validator.test.ts +4 -4
- package/tsup.config.ts +3 -0
- package/typedoc.json +1 -3
- package/dist/character-set.d.ts +0 -22
- package/dist/character-set.d.ts.map +0 -1
- package/dist/character-set.js +0 -36
- package/dist/character-set.js.map +0 -1
- package/dist/check.d.ts +0 -81
- package/dist/check.d.ts.map +0 -1
- package/dist/check.js +0 -218
- package/dist/check.js.map +0 -1
- package/dist/gtin-creator.d.ts +0 -68
- package/dist/gtin-creator.d.ts.map +0 -1
- package/dist/gtin-creator.js +0 -158
- package/dist/gtin-creator.js.map +0 -1
- package/dist/gtin-validator.d.ts +0 -202
- package/dist/gtin-validator.d.ts.map +0 -1
- package/dist/gtin-validator.js +0 -470
- package/dist/gtin-validator.js.map +0 -1
- package/dist/identifier-creator.d.ts +0 -72
- package/dist/identifier-creator.d.ts.map +0 -1
- package/dist/identifier-creator.js +0 -50
- package/dist/identifier-creator.js.map +0 -1
- package/dist/identifier-type.d.ts +0 -58
- package/dist/identifier-type.d.ts.map +0 -1
- package/dist/identifier-type.js +0 -54
- package/dist/identifier-type.js.map +0 -1
- package/dist/identifier-validator.d.ts +0 -174
- package/dist/identifier-validator.d.ts.map +0 -1
- package/dist/identifier-validator.js +0 -145
- package/dist/identifier-validator.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/locale/en/locale-resources.d.ts +0 -43
- package/dist/locale/en/locale-resources.d.ts.map +0 -1
- package/dist/locale/en/locale-resources.js +0 -42
- package/dist/locale/en/locale-resources.js.map +0 -1
- package/dist/locale/fr/locale-resources.d.ts +0 -43
- package/dist/locale/fr/locale-resources.d.ts.map +0 -1
- package/dist/locale/fr/locale-resources.js +0 -42
- package/dist/locale/fr/locale-resources.js.map +0 -1
- package/dist/locale/i18n.d.ts +0 -27
- package/dist/locale/i18n.d.ts.map +0 -1
- package/dist/locale/i18n.js +0 -37
- package/dist/locale/i18n.js.map +0 -1
- package/dist/non-gtin-numeric-identifier-creator.d.ts +0 -30
- package/dist/non-gtin-numeric-identifier-creator.d.ts.map +0 -1
- package/dist/non-gtin-numeric-identifier-creator.js +0 -30
- package/dist/non-gtin-numeric-identifier-creator.js.map +0 -1
- package/dist/non-gtin-numeric-identifier-validator.d.ts +0 -41
- package/dist/non-gtin-numeric-identifier-validator.d.ts.map +0 -1
- package/dist/non-gtin-numeric-identifier-validator.js +0 -40
- package/dist/non-gtin-numeric-identifier-validator.js.map +0 -1
- package/dist/non-numeric-identifier-creator.d.ts +0 -55
- package/dist/non-numeric-identifier-creator.d.ts.map +0 -1
- package/dist/non-numeric-identifier-creator.js +0 -93
- package/dist/non-numeric-identifier-creator.js.map +0 -1
- package/dist/non-numeric-identifier-validator.d.ts +0 -78
- package/dist/non-numeric-identifier-validator.d.ts.map +0 -1
- package/dist/non-numeric-identifier-validator.js +0 -95
- package/dist/non-numeric-identifier-validator.js.map +0 -1
- package/dist/numeric-identifier-creator.d.ts +0 -121
- package/dist/numeric-identifier-creator.d.ts.map +0 -1
- package/dist/numeric-identifier-creator.js +0 -135
- package/dist/numeric-identifier-creator.js.map +0 -1
- package/dist/numeric-identifier-validator.d.ts +0 -76
- package/dist/numeric-identifier-validator.d.ts.map +0 -1
- package/dist/numeric-identifier-validator.js +0 -84
- package/dist/numeric-identifier-validator.js.map +0 -1
- package/dist/prefix-manager.d.ts +0 -224
- package/dist/prefix-manager.d.ts.map +0 -1
- package/dist/prefix-manager.js +0 -369
- package/dist/prefix-manager.js.map +0 -1
- package/dist/prefix-provider.d.ts +0 -27
- package/dist/prefix-provider.d.ts.map +0 -1
- package/dist/prefix-provider.js +0 -2
- package/dist/prefix-provider.js.map +0 -1
- package/dist/prefix-type.d.ts +0 -22
- package/dist/prefix-type.d.ts.map +0 -1
- package/dist/prefix-type.js +0 -18
- package/dist/prefix-type.js.map +0 -1
- package/dist/prefix-validator.d.ts +0 -58
- package/dist/prefix-validator.d.ts.map +0 -1
- package/dist/prefix-validator.js +0 -154
- package/dist/prefix-validator.js.map +0 -1
- package/dist/serializable-numeric-identifier-creator.d.ts +0 -86
- package/dist/serializable-numeric-identifier-creator.d.ts.map +0 -1
- package/dist/serializable-numeric-identifier-creator.js +0 -116
- package/dist/serializable-numeric-identifier-creator.js.map +0 -1
- package/dist/serializable-numeric-identifier-validator.d.ts +0 -79
- package/dist/serializable-numeric-identifier-validator.d.ts.map +0 -1
- package/dist/serializable-numeric-identifier-validator.js +0 -99
- package/dist/serializable-numeric-identifier-validator.js.map +0 -1
package/dist/gtin-validator.d.ts
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { AbstractNumericIdentifierValidator } from "./numeric-identifier-validator.js";
|
|
2
|
-
import { type PrefixType } from "./prefix-type.js";
|
|
3
|
-
/**
|
|
4
|
-
* GTIN types. The numeric values are equal to the lengths of the GTIN types.
|
|
5
|
-
*/
|
|
6
|
-
export declare const GTINTypes: {
|
|
7
|
-
/**
|
|
8
|
-
* GTIN-13.
|
|
9
|
-
*/
|
|
10
|
-
readonly GTIN13: 13;
|
|
11
|
-
/**
|
|
12
|
-
* GTIN-12.
|
|
13
|
-
*/
|
|
14
|
-
readonly GTIN12: 12;
|
|
15
|
-
/**
|
|
16
|
-
* GTIN-8.
|
|
17
|
-
*/
|
|
18
|
-
readonly GTIN8: 8;
|
|
19
|
-
/**
|
|
20
|
-
* GTIN-14.
|
|
21
|
-
*/
|
|
22
|
-
readonly GTIN14: 14;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* GTIN type.
|
|
26
|
-
*/
|
|
27
|
-
export type GTINType = typeof GTINTypes[keyof typeof GTINTypes];
|
|
28
|
-
/**
|
|
29
|
-
* Levels at which GTIN is to be validated.
|
|
30
|
-
*/
|
|
31
|
-
export declare const GTINLevels: {
|
|
32
|
-
/**
|
|
33
|
-
* Any level (level is ignored).
|
|
34
|
-
*/
|
|
35
|
-
readonly Any: 0;
|
|
36
|
-
/**
|
|
37
|
-
* Retail consumer trade item level, supporting GTIN-13, GTIN-12 (optionally zero-suppressed), and GTIN-8.
|
|
38
|
-
*/
|
|
39
|
-
readonly RetailConsumer: 1;
|
|
40
|
-
/**
|
|
41
|
-
* Other than retail consumer trade item level, supporting GTIN-13, GTIN-12 (not zero-suppressed), and GTIN-14.
|
|
42
|
-
*/
|
|
43
|
-
readonly OtherThanRetailConsumer: 2;
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* GTIN level.
|
|
47
|
-
*/
|
|
48
|
-
export type GTINLevel = typeof GTINLevels[keyof typeof GTINLevels];
|
|
49
|
-
/**
|
|
50
|
-
* Restricted Circulation Number reference.
|
|
51
|
-
*/
|
|
52
|
-
export interface RCNReference {
|
|
53
|
-
/**
|
|
54
|
-
* Item reference.
|
|
55
|
-
*/
|
|
56
|
-
itemReference: number;
|
|
57
|
-
/**
|
|
58
|
-
* Price or weight (whole number only).
|
|
59
|
-
*/
|
|
60
|
-
priceOrWeight: number;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* GTIN validator.
|
|
64
|
-
*/
|
|
65
|
-
export declare class GTINValidator extends AbstractNumericIdentifierValidator {
|
|
66
|
-
/**
|
|
67
|
-
* Validation parameters for optional indicator digit.
|
|
68
|
-
*/
|
|
69
|
-
private static readonly OPTIONAL_INDICATOR_DIGIT_VALIDATION;
|
|
70
|
-
/**
|
|
71
|
-
* Validation parameters for zero-suppressed GTIN-12.
|
|
72
|
-
*/
|
|
73
|
-
private static readonly ZERO_SUPPRESSED_GTIN12_VALIDATION;
|
|
74
|
-
/**
|
|
75
|
-
* Constructor.
|
|
76
|
-
*
|
|
77
|
-
* @param gtinType
|
|
78
|
-
* GTIN type.
|
|
79
|
-
*/
|
|
80
|
-
constructor(gtinType: GTINType);
|
|
81
|
-
/**
|
|
82
|
-
* @inheritDoc
|
|
83
|
-
*/
|
|
84
|
-
get gtinType(): GTINType;
|
|
85
|
-
/**
|
|
86
|
-
* @inheritDoc
|
|
87
|
-
*/
|
|
88
|
-
protected validatePrefix(partialIdentifier: string, positionOffset?: number): void;
|
|
89
|
-
/**
|
|
90
|
-
* Zero suppress a GTIN-12.
|
|
91
|
-
*
|
|
92
|
-
* @param gtin12
|
|
93
|
-
* GTIN-12.
|
|
94
|
-
*
|
|
95
|
-
* @returns
|
|
96
|
-
* Zero-suppressed GTIN-12.
|
|
97
|
-
*/
|
|
98
|
-
static zeroSuppress(gtin12: string): string;
|
|
99
|
-
/**
|
|
100
|
-
* Zero expand a zero-suppressed GTIN-12.
|
|
101
|
-
*
|
|
102
|
-
* @param zeroSuppressedGTIN12
|
|
103
|
-
* Zero-suppressed GTIN-12.
|
|
104
|
-
*
|
|
105
|
-
* @returns
|
|
106
|
-
* GTIN-12.
|
|
107
|
-
*/
|
|
108
|
-
static zeroExpand(zeroSuppressedGTIN12: string): string;
|
|
109
|
-
/**
|
|
110
|
-
* Convert a GTIN of any length to a GTIN-14 with an optional indicator digit.
|
|
111
|
-
*
|
|
112
|
-
* @param indicatorDigit
|
|
113
|
-
* Indicator digit. If blank, assumes "0" if the GTIN is not already a GTIN-14.
|
|
114
|
-
*
|
|
115
|
-
* @param gtin
|
|
116
|
-
* GTIN.
|
|
117
|
-
*
|
|
118
|
-
* @returns
|
|
119
|
-
* GTIN-14.
|
|
120
|
-
*/
|
|
121
|
-
static convertToGTIN14(indicatorDigit: string, gtin: string): string;
|
|
122
|
-
/**
|
|
123
|
-
* Normalize a GTIN of any length.
|
|
124
|
-
* - A GTIN-14 that starts with six zeros or a GTIN-13 that starts with five zeros is normalized to GTIN-8.
|
|
125
|
-
* - A GTIN-14 that starts with two zeros or a GTIN-13 that starts with one zero is normalized to GTIN-12.
|
|
126
|
-
* - A GTIN-14 that starts with one zero is normalized to GTIN-13.
|
|
127
|
-
* - Otherwise, the GTIN is unchanged.
|
|
128
|
-
*
|
|
129
|
-
* @param gtin
|
|
130
|
-
* GTIN.
|
|
131
|
-
*
|
|
132
|
-
* @returns
|
|
133
|
-
* Normalized GTIN.
|
|
134
|
-
*/
|
|
135
|
-
static normalize(gtin: string): string;
|
|
136
|
-
/**
|
|
137
|
-
* Validate any GTIN, optionally against a level.
|
|
138
|
-
*
|
|
139
|
-
* @param gtin
|
|
140
|
-
* GTIN.
|
|
141
|
-
*
|
|
142
|
-
* @param gtinLevel
|
|
143
|
-
* Level at which GTIN is to be validated.
|
|
144
|
-
*/
|
|
145
|
-
static validateAny(gtin: string, gtinLevel?: GTINLevel): void;
|
|
146
|
-
/**
|
|
147
|
-
* Validate a GTIN-14.
|
|
148
|
-
*
|
|
149
|
-
* @param gtin14
|
|
150
|
-
* GTIN-14.
|
|
151
|
-
*/
|
|
152
|
-
static validateGTIN14(gtin14: string): void;
|
|
153
|
-
/**
|
|
154
|
-
* Parse a Restricted Circulation Number (RCN) using a variable measure trade item format. The format is a 12- or
|
|
155
|
-
* 13-character string (for RCN-12 or RCN-13 respectively), containing the following:
|
|
156
|
-
*
|
|
157
|
-
* - '2' - The first character of the RCN.
|
|
158
|
-
* - '0'-'9' - The second character of the RCN (RCN-13 only).
|
|
159
|
-
* - 'I' - One or more, in sequence, for the item reference.
|
|
160
|
-
* - 'P' - One or more, in sequence, for the price or weight.
|
|
161
|
-
* - 'V' - Zero or one, for the price or weight check digit.
|
|
162
|
-
* - 'C' - The check digit of the entire RCN.
|
|
163
|
-
*
|
|
164
|
-
* The 'I', 'P', and 'V' formats may be in any order.
|
|
165
|
-
*
|
|
166
|
-
* Some examples:
|
|
167
|
-
*
|
|
168
|
-
* - 2IIIIIVPPPPC - RCN-12 with a five-digit item reference, a price or weight check digit, and a four-digit price
|
|
169
|
-
* or weight.
|
|
170
|
-
* - 23IIIIVPPPPPC - RCN-13 with a four-digit item reference, a price or weight check digit, and a five-digit price
|
|
171
|
-
* or weight.
|
|
172
|
-
* - 2IIIIIIPPPPC - RCN-12 with a six-digit item reference and a four-digit price or eight.
|
|
173
|
-
* - 29IIIIIPPPPPC - RCN-13 with a five-digit item reference and a five-digit price or weight.
|
|
174
|
-
*
|
|
175
|
-
* @param format
|
|
176
|
-
* Format.
|
|
177
|
-
*
|
|
178
|
-
* @param rcn
|
|
179
|
-
* RCN.
|
|
180
|
-
*
|
|
181
|
-
* @returns
|
|
182
|
-
* RCN reference.
|
|
183
|
-
*/
|
|
184
|
-
static parseVariableMeasureRCN(format: string, rcn: string): RCNReference;
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* GTIN-13 validator.
|
|
188
|
-
*/
|
|
189
|
-
export declare const GTIN13_VALIDATOR: GTINValidator;
|
|
190
|
-
/**
|
|
191
|
-
* GTIN-12 validator.
|
|
192
|
-
*/
|
|
193
|
-
export declare const GTIN12_VALIDATOR: GTINValidator;
|
|
194
|
-
/**
|
|
195
|
-
* GTIN-8 validator.
|
|
196
|
-
*/
|
|
197
|
-
export declare const GTIN8_VALIDATOR: GTINValidator;
|
|
198
|
-
/**
|
|
199
|
-
* GTIN validators indexed by prefix type.
|
|
200
|
-
*/
|
|
201
|
-
export declare const GTIN_VALIDATORS: Record<PrefixType, GTINValidator>;
|
|
202
|
-
//# sourceMappingURL=gtin-validator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gtin-validator.d.ts","sourceRoot":"","sources":["../src/gtin-validator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kCAAkC,EAAe,MAAM,mCAAmC,CAAC;AACpG,OAAO,EAAE,KAAK,UAAU,EAAe,MAAM,kBAAkB,CAAC;AAGhE;;GAEG;AACH,eAAO,MAAM,SAAS;IAClB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEG,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,SAAS,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,UAAU;IACnB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEG,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,UAAU,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,kCAAkC;IACjE;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mCAAmC,CAIzD;IAEF;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iCAAiC,CAGvD;IAEF;;;;;OAKG;gBACS,QAAQ,EAAE,QAAQ;IAyB9B;;OAEG;IACH,IAAI,QAAQ,IAAI,QAAQ,CAGvB;IAED;;OAEG;cACgB,cAAc,CAAC,iBAAiB,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI;IAK3F;;;;;;;;OAQG;IACH,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IA4B3C;;;;;;;;OAQG;IACH,MAAM,CAAC,UAAU,CAAC,oBAAoB,EAAE,MAAM,GAAG,MAAM;IA+BvD;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,eAAe,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAkBpE;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAgEtC;;;;;;;;OAQG;IACH,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,SAA0B,GAAG,IAAI;IA2D7E;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAQ3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,MAAM,CAAC,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,YAAY;CAgG5E;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,eAAsC,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,gBAAgB,eAAsC,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,eAAe,eAAqC,CAAC;AAElE;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,UAAU,EAAE,aAAa,CAI7D,CAAC"}
|
package/dist/gtin-validator.js
DELETED
|
@@ -1,470 +0,0 @@
|
|
|
1
|
-
import { NUMERIC_CREATOR } from "@aidc-toolkit/utility";
|
|
2
|
-
import { checkDigit, hasValidCheckDigit, isValidPriceOrWeightCheckDigit } from "./check.js";
|
|
3
|
-
import { IdentifierTypes } from "./identifier-type.js";
|
|
4
|
-
import { i18nextGS1 } from "./locale/i18n.js";
|
|
5
|
-
import { AbstractNumericIdentifierValidator, LeaderTypes } from "./numeric-identifier-validator.js";
|
|
6
|
-
import { PrefixTypes } from "./prefix-type.js";
|
|
7
|
-
import { PrefixValidator } from "./prefix-validator.js";
|
|
8
|
-
/**
|
|
9
|
-
* GTIN types. The numeric values are equal to the lengths of the GTIN types.
|
|
10
|
-
*/
|
|
11
|
-
export const GTINTypes = {
|
|
12
|
-
/**
|
|
13
|
-
* GTIN-13.
|
|
14
|
-
*/
|
|
15
|
-
GTIN13: 13,
|
|
16
|
-
/**
|
|
17
|
-
* GTIN-12.
|
|
18
|
-
*/
|
|
19
|
-
GTIN12: 12,
|
|
20
|
-
/**
|
|
21
|
-
* GTIN-8.
|
|
22
|
-
*/
|
|
23
|
-
GTIN8: 8,
|
|
24
|
-
/**
|
|
25
|
-
* GTIN-14.
|
|
26
|
-
*/
|
|
27
|
-
GTIN14: 14
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Levels at which GTIN is to be validated.
|
|
31
|
-
*/
|
|
32
|
-
export const GTINLevels = {
|
|
33
|
-
/**
|
|
34
|
-
* Any level (level is ignored).
|
|
35
|
-
*/
|
|
36
|
-
Any: 0,
|
|
37
|
-
/**
|
|
38
|
-
* Retail consumer trade item level, supporting GTIN-13, GTIN-12 (optionally zero-suppressed), and GTIN-8.
|
|
39
|
-
*/
|
|
40
|
-
RetailConsumer: 1,
|
|
41
|
-
/**
|
|
42
|
-
* Other than retail consumer trade item level, supporting GTIN-13, GTIN-12 (not zero-suppressed), and GTIN-14.
|
|
43
|
-
*/
|
|
44
|
-
OtherThanRetailConsumer: 2
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* GTIN validator.
|
|
48
|
-
*/
|
|
49
|
-
export class GTINValidator extends AbstractNumericIdentifierValidator {
|
|
50
|
-
/**
|
|
51
|
-
* Validation parameters for optional indicator digit.
|
|
52
|
-
*/
|
|
53
|
-
static OPTIONAL_INDICATOR_DIGIT_VALIDATION = {
|
|
54
|
-
minimumLength: 0,
|
|
55
|
-
maximumLength: 1,
|
|
56
|
-
component: () => i18nextGS1.t("Identifier.indicatorDigit")
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Validation parameters for zero-suppressed GTIN-12.
|
|
60
|
-
*/
|
|
61
|
-
static ZERO_SUPPRESSED_GTIN12_VALIDATION = {
|
|
62
|
-
minimumLength: 8,
|
|
63
|
-
maximumLength: 8
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Constructor.
|
|
67
|
-
*
|
|
68
|
-
* @param gtinType
|
|
69
|
-
* GTIN type.
|
|
70
|
-
*/
|
|
71
|
-
constructor(gtinType) {
|
|
72
|
-
let prefixType;
|
|
73
|
-
// Determine the prefix type based on the GTIN type.
|
|
74
|
-
switch (gtinType) {
|
|
75
|
-
case GTINTypes.GTIN13:
|
|
76
|
-
prefixType = PrefixTypes.GS1CompanyPrefix;
|
|
77
|
-
break;
|
|
78
|
-
case GTINTypes.GTIN12:
|
|
79
|
-
prefixType = PrefixTypes.UPCCompanyPrefix;
|
|
80
|
-
break;
|
|
81
|
-
case GTINTypes.GTIN8:
|
|
82
|
-
prefixType = PrefixTypes.GS18Prefix;
|
|
83
|
-
break;
|
|
84
|
-
default:
|
|
85
|
-
// Should never get here.
|
|
86
|
-
throw new Error("Not supported");
|
|
87
|
-
}
|
|
88
|
-
super(IdentifierTypes.GTIN, prefixType, gtinType, LeaderTypes.IndicatorDigit);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* @inheritDoc
|
|
92
|
-
*/
|
|
93
|
-
get gtinType() {
|
|
94
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Length maps to GTIN type.
|
|
95
|
-
return this.length;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* @inheritDoc
|
|
99
|
-
*/
|
|
100
|
-
validatePrefix(partialIdentifier, positionOffset) {
|
|
101
|
-
// Delegate to prefix validator requiring exact match for prefix type.
|
|
102
|
-
PrefixValidator.validate(this.prefixType, false, false, partialIdentifier, true, true, positionOffset);
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Zero suppress a GTIN-12.
|
|
106
|
-
*
|
|
107
|
-
* @param gtin12
|
|
108
|
-
* GTIN-12.
|
|
109
|
-
*
|
|
110
|
-
* @returns
|
|
111
|
-
* Zero-suppressed GTIN-12.
|
|
112
|
-
*/
|
|
113
|
-
static zeroSuppress(gtin12) {
|
|
114
|
-
GTIN12_VALIDATOR.validate(gtin12);
|
|
115
|
-
// Convert to individual digits.
|
|
116
|
-
const d = Array.from(gtin12);
|
|
117
|
-
let zeroSuppressedGTIN12;
|
|
118
|
-
// All rules require that digits in positions 1, 5, and 6 be zero.
|
|
119
|
-
if (d[0] === "0" && d[6] === "0" && d[7] === "0") {
|
|
120
|
-
if (d[10] >= "5" && d[8] === "0" && d[9] === "0" && d[5] !== "0") {
|
|
121
|
-
zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[4]}${d[5]}${d[10]}${d[11]}`;
|
|
122
|
-
}
|
|
123
|
-
else if (d[5] === "0" && d[8] === "0" && d[9] === "0" && d[4] !== "0") {
|
|
124
|
-
zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[4]}${d[10]}4${d[11]}`;
|
|
125
|
-
}
|
|
126
|
-
else if (d[3] <= "2" && d[4] === "0" && d[5] === "0") {
|
|
127
|
-
zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[8]}${d[9]}${d[10]}${d[3]}${d[11]}`;
|
|
128
|
-
}
|
|
129
|
-
else if (d[3] >= "3" && d[4] === "0" && d[5] === "0" && d[8] === "0") {
|
|
130
|
-
zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[9]}${d[10]}3${d[11]}`;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
if (zeroSuppressedGTIN12 === undefined) {
|
|
134
|
-
throw new RangeError(i18nextGS1.t("Identifier.invalidZeroSuppressibleGTIN12"));
|
|
135
|
-
}
|
|
136
|
-
return zeroSuppressedGTIN12;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Zero expand a zero-suppressed GTIN-12.
|
|
140
|
-
*
|
|
141
|
-
* @param zeroSuppressedGTIN12
|
|
142
|
-
* Zero-suppressed GTIN-12.
|
|
143
|
-
*
|
|
144
|
-
* @returns
|
|
145
|
-
* GTIN-12.
|
|
146
|
-
*/
|
|
147
|
-
static zeroExpand(zeroSuppressedGTIN12) {
|
|
148
|
-
NUMERIC_CREATOR.validate(zeroSuppressedGTIN12, GTINValidator.ZERO_SUPPRESSED_GTIN12_VALIDATION);
|
|
149
|
-
// Convert to individual digits.
|
|
150
|
-
const d = Array.from(zeroSuppressedGTIN12);
|
|
151
|
-
let gtin12;
|
|
152
|
-
// Zero-suppressed GTIN-12 always starts with 0.
|
|
153
|
-
if (d[0] === "0") {
|
|
154
|
-
if (d[6] >= "5" && d[5] !== "0") {
|
|
155
|
-
gtin12 = `0${d[1]}${d[2]}${d[3]}${d[4]}${d[5]}0000${d[6]}${d[7]}`;
|
|
156
|
-
}
|
|
157
|
-
else if (d[6] === "4" && d[4] !== "0") {
|
|
158
|
-
gtin12 = `0${d[1]}${d[2]}${d[3]}${d[4]}00000${d[5]}${d[7]}`;
|
|
159
|
-
}
|
|
160
|
-
else if (d[6] <= "2") {
|
|
161
|
-
gtin12 = `0${d[1]}${d[2]}${d[6]}0000${d[3]}${d[4]}${d[5]}${d[7]}`;
|
|
162
|
-
}
|
|
163
|
-
else if (d[6] === "3" && d[3] >= "3") {
|
|
164
|
-
gtin12 = `0${d[1]}${d[2]}${d[3]}00000${d[4]}${d[5]}${d[7]}`;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
if (gtin12 === undefined) {
|
|
168
|
-
throw new RangeError(i18nextGS1.t("Identifier.invalidZeroSuppressedGTIN12"));
|
|
169
|
-
}
|
|
170
|
-
// Make sure that resulting GTIN-12 is valid.
|
|
171
|
-
GTIN12_VALIDATOR.validate(gtin12);
|
|
172
|
-
return gtin12;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Convert a GTIN of any length to a GTIN-14 with an optional indicator digit.
|
|
176
|
-
*
|
|
177
|
-
* @param indicatorDigit
|
|
178
|
-
* Indicator digit. If blank, assumes "0" if the GTIN is not already a GTIN-14.
|
|
179
|
-
*
|
|
180
|
-
* @param gtin
|
|
181
|
-
* GTIN.
|
|
182
|
-
*
|
|
183
|
-
* @returns
|
|
184
|
-
* GTIN-14.
|
|
185
|
-
*/
|
|
186
|
-
static convertToGTIN14(indicatorDigit, gtin) {
|
|
187
|
-
GTINValidator.validateAny(gtin);
|
|
188
|
-
NUMERIC_CREATOR.validate(indicatorDigit, GTINValidator.OPTIONAL_INDICATOR_DIGIT_VALIDATION);
|
|
189
|
-
// Check digit doesn't change by prepending zeros.
|
|
190
|
-
let gtin14 = gtin.padStart(GTINTypes.GTIN14, "0");
|
|
191
|
-
// If indicator digit provided and is different, recalculate the check digit.
|
|
192
|
-
if (indicatorDigit.length !== 0 && indicatorDigit !== gtin14.charAt(0)) {
|
|
193
|
-
const partialGTIN14 = indicatorDigit + gtin14.substring(1, GTINTypes.GTIN14 - 1);
|
|
194
|
-
gtin14 = partialGTIN14 + checkDigit(partialGTIN14);
|
|
195
|
-
}
|
|
196
|
-
return gtin14;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Normalize a GTIN of any length.
|
|
200
|
-
* - A GTIN-14 that starts with six zeros or a GTIN-13 that starts with five zeros is normalized to GTIN-8.
|
|
201
|
-
* - A GTIN-14 that starts with two zeros or a GTIN-13 that starts with one zero is normalized to GTIN-12.
|
|
202
|
-
* - A GTIN-14 that starts with one zero is normalized to GTIN-13.
|
|
203
|
-
* - Otherwise, the GTIN is unchanged.
|
|
204
|
-
*
|
|
205
|
-
* @param gtin
|
|
206
|
-
* GTIN.
|
|
207
|
-
*
|
|
208
|
-
* @returns
|
|
209
|
-
* Normalized GTIN.
|
|
210
|
-
*/
|
|
211
|
-
static normalize(gtin) {
|
|
212
|
-
const gtinLength = gtin.length;
|
|
213
|
-
let normalizedGTIN;
|
|
214
|
-
switch (gtinLength) {
|
|
215
|
-
case GTINTypes.GTIN13:
|
|
216
|
-
if (!gtin.startsWith("0")) {
|
|
217
|
-
// GTIN is GTIN-13.
|
|
218
|
-
normalizedGTIN = gtin;
|
|
219
|
-
}
|
|
220
|
-
else if (!gtin.startsWith("00000")) {
|
|
221
|
-
// GTIN is GTIN-12.
|
|
222
|
-
normalizedGTIN = gtin.substring(1);
|
|
223
|
-
}
|
|
224
|
-
else if (!gtin.startsWith("000000")) {
|
|
225
|
-
// GTIN is GTIN-8.
|
|
226
|
-
normalizedGTIN = gtin.substring(5);
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
throw new RangeError(i18nextGS1.t("Identifier.invalidZeroSuppressedGTIN12AsGTIN13"));
|
|
230
|
-
}
|
|
231
|
-
break;
|
|
232
|
-
case GTINTypes.GTIN12:
|
|
233
|
-
// GTIN is GTIN-12.
|
|
234
|
-
normalizedGTIN = gtin;
|
|
235
|
-
break;
|
|
236
|
-
case GTINTypes.GTIN8:
|
|
237
|
-
if (!gtin.startsWith("0")) {
|
|
238
|
-
// GTIN is GTIN-8.
|
|
239
|
-
normalizedGTIN = gtin;
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
// GTIN is zero-suppressed GTIN-12.
|
|
243
|
-
normalizedGTIN = GTINValidator.zeroExpand(gtin);
|
|
244
|
-
}
|
|
245
|
-
break;
|
|
246
|
-
case GTINTypes.GTIN14:
|
|
247
|
-
if (!gtin.startsWith("0")) {
|
|
248
|
-
// GTIN is GTIN-14.
|
|
249
|
-
normalizedGTIN = gtin;
|
|
250
|
-
}
|
|
251
|
-
else if (!gtin.startsWith("00")) {
|
|
252
|
-
// GTIN is GTIN-13.
|
|
253
|
-
normalizedGTIN = gtin.substring(1);
|
|
254
|
-
}
|
|
255
|
-
else if (!gtin.startsWith("000000")) {
|
|
256
|
-
// GTIN is GTIN-12.
|
|
257
|
-
normalizedGTIN = gtin.substring(2);
|
|
258
|
-
}
|
|
259
|
-
else if (!gtin.startsWith("0000000")) {
|
|
260
|
-
// GTIN is GTIN-8.
|
|
261
|
-
normalizedGTIN = gtin.substring(6);
|
|
262
|
-
}
|
|
263
|
-
else {
|
|
264
|
-
throw new RangeError(i18nextGS1.t("Identifier.invalidZeroSuppressedGTIN12AsGTIN14"));
|
|
265
|
-
}
|
|
266
|
-
break;
|
|
267
|
-
default:
|
|
268
|
-
throw new RangeError(i18nextGS1.t("Identifier.invalidGTINLength"));
|
|
269
|
-
}
|
|
270
|
-
// Validation applies to the normalized GTIN.
|
|
271
|
-
GTINValidator.validateAny(normalizedGTIN);
|
|
272
|
-
return normalizedGTIN;
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Validate any GTIN, optionally against a level.
|
|
276
|
-
*
|
|
277
|
-
* @param gtin
|
|
278
|
-
* GTIN.
|
|
279
|
-
*
|
|
280
|
-
* @param gtinLevel
|
|
281
|
-
* Level at which GTIN is to be validated.
|
|
282
|
-
*/
|
|
283
|
-
static validateAny(gtin, gtinLevel = GTINLevels.Any) {
|
|
284
|
-
// Assume length-validated GTIN is the GTIN (true for all except zero-suppressed GTIN-12).
|
|
285
|
-
let lengthValidatedGTIN = gtin;
|
|
286
|
-
let gtinLevelRestriction;
|
|
287
|
-
switch (gtin.length) {
|
|
288
|
-
case GTINTypes.GTIN13:
|
|
289
|
-
if (gtin.startsWith("0")) {
|
|
290
|
-
throw new RangeError(i18nextGS1.t("Identifier.invalidGTIN13AtRetail"));
|
|
291
|
-
}
|
|
292
|
-
// Validate prefix requiring exact match for prefix type.
|
|
293
|
-
PrefixValidator.validate(PrefixTypes.GS1CompanyPrefix, false, false, gtin, true, true);
|
|
294
|
-
gtinLevelRestriction = GTINLevels.Any;
|
|
295
|
-
break;
|
|
296
|
-
case GTINTypes.GTIN12:
|
|
297
|
-
// Validate prefix requiring exact match for prefix type.
|
|
298
|
-
PrefixValidator.validate(PrefixTypes.UPCCompanyPrefix, false, false, gtin, true, true);
|
|
299
|
-
gtinLevelRestriction = GTINLevels.Any;
|
|
300
|
-
break;
|
|
301
|
-
case GTINTypes.GTIN8:
|
|
302
|
-
// Zero-suppressed GTIN-12 always starts with 0.
|
|
303
|
-
if (!gtin.startsWith("0")) {
|
|
304
|
-
// Validate prefix requiring exact match for prefix type.
|
|
305
|
-
PrefixValidator.validate(PrefixTypes.GS18Prefix, false, false, gtin, true, true);
|
|
306
|
-
}
|
|
307
|
-
else {
|
|
308
|
-
lengthValidatedGTIN = GTINValidator.zeroExpand(gtin);
|
|
309
|
-
}
|
|
310
|
-
gtinLevelRestriction = GTINLevels.RetailConsumer;
|
|
311
|
-
break;
|
|
312
|
-
case GTINTypes.GTIN14:
|
|
313
|
-
// Validate prefix supporting any prefix type.
|
|
314
|
-
PrefixValidator.validate(PrefixTypes.GS1CompanyPrefix, true, true, gtin.substring(1), true, true);
|
|
315
|
-
gtinLevelRestriction = GTINLevels.OtherThanRetailConsumer;
|
|
316
|
-
break;
|
|
317
|
-
default:
|
|
318
|
-
throw new RangeError(i18nextGS1.t("Identifier.invalidGTINLength"));
|
|
319
|
-
}
|
|
320
|
-
// Validating the check digit will also validate the characters.
|
|
321
|
-
if (!hasValidCheckDigit(lengthValidatedGTIN)) {
|
|
322
|
-
throw new RangeError(i18nextGS1.t("Identifier.invalidCheckDigit"));
|
|
323
|
-
}
|
|
324
|
-
// Validate against level if required.
|
|
325
|
-
if (gtinLevel !== GTINLevels.Any && gtinLevelRestriction !== GTINLevels.Any && gtinLevelRestriction !== gtinLevel) {
|
|
326
|
-
throw new RangeError(i18nextGS1.t(gtinLevel === GTINLevels.RetailConsumer ? "Identifier.invalidGTINAtRetail" : "Identifier.invalidGTINAtOtherThanRetail"));
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* Validate a GTIN-14.
|
|
331
|
-
*
|
|
332
|
-
* @param gtin14
|
|
333
|
-
* GTIN-14.
|
|
334
|
-
*/
|
|
335
|
-
static validateGTIN14(gtin14) {
|
|
336
|
-
if (gtin14.length !== GTINTypes.GTIN14) {
|
|
337
|
-
throw new RangeError(i18nextGS1.t("Identifier.invalidGTIN14Length"));
|
|
338
|
-
}
|
|
339
|
-
GTINValidator.validateAny(gtin14);
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Parse a Restricted Circulation Number (RCN) using a variable measure trade item format. The format is a 12- or
|
|
343
|
-
* 13-character string (for RCN-12 or RCN-13 respectively), containing the following:
|
|
344
|
-
*
|
|
345
|
-
* - '2' - The first character of the RCN.
|
|
346
|
-
* - '0'-'9' - The second character of the RCN (RCN-13 only).
|
|
347
|
-
* - 'I' - One or more, in sequence, for the item reference.
|
|
348
|
-
* - 'P' - One or more, in sequence, for the price or weight.
|
|
349
|
-
* - 'V' - Zero or one, for the price or weight check digit.
|
|
350
|
-
* - 'C' - The check digit of the entire RCN.
|
|
351
|
-
*
|
|
352
|
-
* The 'I', 'P', and 'V' formats may be in any order.
|
|
353
|
-
*
|
|
354
|
-
* Some examples:
|
|
355
|
-
*
|
|
356
|
-
* - 2IIIIIVPPPPC - RCN-12 with a five-digit item reference, a price or weight check digit, and a four-digit price
|
|
357
|
-
* or weight.
|
|
358
|
-
* - 23IIIIVPPPPPC - RCN-13 with a four-digit item reference, a price or weight check digit, and a five-digit price
|
|
359
|
-
* or weight.
|
|
360
|
-
* - 2IIIIIIPPPPC - RCN-12 with a six-digit item reference and a four-digit price or eight.
|
|
361
|
-
* - 29IIIIIPPPPPC - RCN-13 with a five-digit item reference and a five-digit price or weight.
|
|
362
|
-
*
|
|
363
|
-
* @param format
|
|
364
|
-
* Format.
|
|
365
|
-
*
|
|
366
|
-
* @param rcn
|
|
367
|
-
* RCN.
|
|
368
|
-
*
|
|
369
|
-
* @returns
|
|
370
|
-
* RCN reference.
|
|
371
|
-
*/
|
|
372
|
-
static parseVariableMeasureRCN(format, rcn) {
|
|
373
|
-
const formatLength = format.length;
|
|
374
|
-
if (rcn.length !== formatLength) {
|
|
375
|
-
throw new RangeError(i18nextGS1.t("Identifier.invalidRCNLength"));
|
|
376
|
-
}
|
|
377
|
-
let validFormat = formatLength === 12 || formatLength === 13;
|
|
378
|
-
let validRCNPrefix = true;
|
|
379
|
-
let buildingItemReference = false;
|
|
380
|
-
let itemReference = "";
|
|
381
|
-
let buildingPriceOrWeight = false;
|
|
382
|
-
let priceOrWeight = "";
|
|
383
|
-
let priceOrWeightCheckDigit = "";
|
|
384
|
-
for (let index = 0; validFormat && index < formatLength; index++) {
|
|
385
|
-
const formatChar = format.charAt(index);
|
|
386
|
-
const rcnChar = rcn.charAt(index);
|
|
387
|
-
if (index === 0) {
|
|
388
|
-
validFormat = formatChar === "2";
|
|
389
|
-
validRCNPrefix = rcnChar === "2";
|
|
390
|
-
}
|
|
391
|
-
else if (formatLength === 13 && index === 1) {
|
|
392
|
-
validFormat = NUMERIC_CREATOR.characterIndex(formatChar) !== undefined;
|
|
393
|
-
validRCNPrefix = rcnChar === formatChar;
|
|
394
|
-
}
|
|
395
|
-
else if (index === formatLength - 1) {
|
|
396
|
-
validFormat = formatChar === "C";
|
|
397
|
-
}
|
|
398
|
-
else {
|
|
399
|
-
switch (formatChar) {
|
|
400
|
-
case "I":
|
|
401
|
-
if (!buildingItemReference) {
|
|
402
|
-
// Item reference can't appear more than once.
|
|
403
|
-
validFormat = itemReference === "";
|
|
404
|
-
buildingItemReference = true;
|
|
405
|
-
buildingPriceOrWeight = false;
|
|
406
|
-
}
|
|
407
|
-
itemReference += rcnChar;
|
|
408
|
-
break;
|
|
409
|
-
case "P":
|
|
410
|
-
if (!buildingPriceOrWeight) {
|
|
411
|
-
// Price or weight can't appear more than once.
|
|
412
|
-
validFormat = priceOrWeight === "";
|
|
413
|
-
buildingPriceOrWeight = true;
|
|
414
|
-
buildingItemReference = false;
|
|
415
|
-
}
|
|
416
|
-
priceOrWeight += rcnChar;
|
|
417
|
-
break;
|
|
418
|
-
case "V":
|
|
419
|
-
// Price or weight check digit can't appear more than once.
|
|
420
|
-
validFormat = priceOrWeightCheckDigit === "";
|
|
421
|
-
buildingItemReference = false;
|
|
422
|
-
buildingPriceOrWeight = false;
|
|
423
|
-
priceOrWeightCheckDigit = rcnChar;
|
|
424
|
-
break;
|
|
425
|
-
default:
|
|
426
|
-
validFormat = false;
|
|
427
|
-
break;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
validFormat &&= itemReference !== "" && priceOrWeight !== "";
|
|
432
|
-
if (!validFormat) {
|
|
433
|
-
throw new RangeError(i18nextGS1.t("Identifier.invalidVariableMeasureRCNFormat"));
|
|
434
|
-
}
|
|
435
|
-
if (!validRCNPrefix) {
|
|
436
|
-
throw new RangeError(i18nextGS1.t("Identifier.invalidVariableMeasureRCNPrefix"));
|
|
437
|
-
}
|
|
438
|
-
if (priceOrWeightCheckDigit !== "" && !isValidPriceOrWeightCheckDigit(priceOrWeight, priceOrWeightCheckDigit)) {
|
|
439
|
-
throw new RangeError(i18nextGS1.t("Identifier.invalidVariableMeasurePriceOrWeight"));
|
|
440
|
-
}
|
|
441
|
-
if (!hasValidCheckDigit(rcn)) {
|
|
442
|
-
throw new RangeError(i18nextGS1.t("Identifier.invalidCheckDigit"));
|
|
443
|
-
}
|
|
444
|
-
return {
|
|
445
|
-
itemReference: Number(itemReference),
|
|
446
|
-
priceOrWeight: Number(priceOrWeight)
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* GTIN-13 validator.
|
|
452
|
-
*/
|
|
453
|
-
export const GTIN13_VALIDATOR = new GTINValidator(GTINTypes.GTIN13);
|
|
454
|
-
/**
|
|
455
|
-
* GTIN-12 validator.
|
|
456
|
-
*/
|
|
457
|
-
export const GTIN12_VALIDATOR = new GTINValidator(GTINTypes.GTIN12);
|
|
458
|
-
/**
|
|
459
|
-
* GTIN-8 validator.
|
|
460
|
-
*/
|
|
461
|
-
export const GTIN8_VALIDATOR = new GTINValidator(GTINTypes.GTIN8);
|
|
462
|
-
/**
|
|
463
|
-
* GTIN validators indexed by prefix type.
|
|
464
|
-
*/
|
|
465
|
-
export const GTIN_VALIDATORS = {
|
|
466
|
-
[PrefixTypes.GS1CompanyPrefix]: GTIN13_VALIDATOR,
|
|
467
|
-
[PrefixTypes.UPCCompanyPrefix]: GTIN12_VALIDATOR,
|
|
468
|
-
[PrefixTypes.GS18Prefix]: GTIN8_VALIDATOR
|
|
469
|
-
};
|
|
470
|
-
//# sourceMappingURL=gtin-validator.js.map
|