@aidc-toolkit/gs1 1.0.31-beta → 1.0.33-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.
Files changed (110) hide show
  1. package/README.md +290 -17
  2. package/dist/character-set.d.ts +17 -2
  3. package/dist/character-set.d.ts.map +1 -1
  4. package/dist/character-set.js +44 -11
  5. package/dist/character-set.js.map +1 -1
  6. package/dist/gcp-length-cache.d.ts +81 -0
  7. package/dist/gcp-length-cache.d.ts.map +1 -0
  8. package/dist/gcp-length-cache.js +232 -0
  9. package/dist/gcp-length-cache.js.map +1 -0
  10. package/dist/gcp-length-data.d.ts +108 -0
  11. package/dist/gcp-length-data.d.ts.map +1 -0
  12. package/dist/gcp-length-data.js +53 -0
  13. package/dist/gcp-length-data.js.map +1 -0
  14. package/dist/gcp-length.d.ts +61 -0
  15. package/dist/gcp-length.d.ts.map +1 -0
  16. package/dist/gcp-length.js +300 -0
  17. package/dist/gcp-length.js.map +1 -0
  18. package/dist/gtin-creator.d.ts +0 -17
  19. package/dist/gtin-creator.d.ts.map +1 -1
  20. package/dist/gtin-creator.js +1 -93
  21. package/dist/gtin-creator.js.map +1 -1
  22. package/dist/gtin-validator.d.ts +1 -46
  23. package/dist/gtin-validator.d.ts.map +1 -1
  24. package/dist/gtin-validator.js +31 -125
  25. package/dist/gtin-validator.js.map +1 -1
  26. package/dist/identifier-validator.d.ts +1 -4
  27. package/dist/identifier-validator.d.ts.map +1 -1
  28. package/dist/identifier-validator.js +2 -5
  29. package/dist/identifier-validator.js.map +1 -1
  30. package/dist/index.d.ts +5 -1
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +4 -0
  33. package/dist/index.js.map +1 -1
  34. package/dist/locale/en/locale-resources.d.ts +39 -35
  35. package/dist/locale/en/locale-resources.d.ts.map +1 -1
  36. package/dist/locale/en/locale-resources.js +6 -2
  37. package/dist/locale/en/locale-resources.js.map +1 -1
  38. package/dist/locale/fr/locale-resources.d.ts +39 -35
  39. package/dist/locale/fr/locale-resources.d.ts.map +1 -1
  40. package/dist/locale/fr/locale-resources.js +6 -2
  41. package/dist/locale/fr/locale-resources.js.map +1 -1
  42. package/dist/locale/i18n.d.ts +4 -4
  43. package/dist/locale/i18n.d.ts.map +1 -1
  44. package/dist/locale/i18n.js +6 -7
  45. package/dist/locale/i18n.js.map +1 -1
  46. package/dist/non-numeric-identifier-validator.js +1 -1
  47. package/dist/non-numeric-identifier-validator.js.map +1 -1
  48. package/dist/numeric-identifier-validator.d.ts.map +1 -1
  49. package/dist/numeric-identifier-validator.js +2 -2
  50. package/dist/numeric-identifier-validator.js.map +1 -1
  51. package/dist/prefix-manager.d.ts +35 -0
  52. package/dist/prefix-manager.d.ts.map +1 -1
  53. package/dist/prefix-manager.js +56 -0
  54. package/dist/prefix-manager.js.map +1 -1
  55. package/dist/prefix-validator.d.ts +5 -4
  56. package/dist/prefix-validator.d.ts.map +1 -1
  57. package/dist/prefix-validator.js +18 -22
  58. package/dist/prefix-validator.js.map +1 -1
  59. package/dist/serializable-numeric-identifier-validator.d.ts +26 -0
  60. package/dist/serializable-numeric-identifier-validator.d.ts.map +1 -1
  61. package/dist/serializable-numeric-identifier-validator.js +19 -0
  62. package/dist/serializable-numeric-identifier-validator.js.map +1 -1
  63. package/dist/variable-measure.d.ts +68 -0
  64. package/dist/variable-measure.d.ts.map +1 -0
  65. package/dist/variable-measure.js +210 -0
  66. package/dist/variable-measure.js.map +1 -0
  67. package/dist/verified-by-gs1.d.ts +22 -0
  68. package/dist/verified-by-gs1.d.ts.map +1 -0
  69. package/dist/verified-by-gs1.js +46 -0
  70. package/dist/verified-by-gs1.js.map +1 -0
  71. package/package.json +12 -11
  72. package/src/character-set.ts +55 -11
  73. package/src/gcp-length-cache.ts +271 -0
  74. package/src/gcp-length-data.ts +136 -0
  75. package/src/gcp-length.ts +380 -0
  76. package/src/gtin-creator.ts +1 -117
  77. package/src/gtin-validator.ts +42 -173
  78. package/src/identifier-validator.ts +2 -5
  79. package/src/index.ts +7 -1
  80. package/src/locale/en/locale-resources.ts +7 -3
  81. package/src/locale/fr/locale-resources.ts +7 -3
  82. package/src/locale/i18n.ts +7 -8
  83. package/src/locale/i18next.d.ts +2 -0
  84. package/src/non-numeric-identifier-validator.ts +1 -1
  85. package/src/numeric-identifier-validator.ts +3 -3
  86. package/src/prefix-manager.ts +65 -0
  87. package/src/prefix-validator.ts +19 -23
  88. package/src/serializable-numeric-identifier-validator.ts +36 -0
  89. package/src/variable-measure.ts +268 -0
  90. package/src/verified-by-gs1.ts +54 -0
  91. package/test/character-set.test.ts +46 -0
  92. package/test/creator.test.ts +5 -5
  93. package/test/data/gcpprefixformatlist-1.json +662625 -0
  94. package/test/data/gcpprefixformatlist-2.json +735431 -0
  95. package/test/gcp-length.test.ts +344 -0
  96. package/test/gtin-creator.ts +4 -4
  97. package/test/gtin-validator.test.ts +205 -113
  98. package/test/gtin-validator.ts +30 -0
  99. package/test/identifier-creator.ts +6 -6
  100. package/test/non-numeric-identifier-creator.ts +0 -8
  101. package/test/non-serializable-numeric-identifier-creator.ts +4 -54
  102. package/test/numeric-identifier-creator.ts +4 -4
  103. package/test/prefix-manager.test.ts +5 -5
  104. package/test/serializable-numeric-identifier-creator.ts +32 -19
  105. package/test/validator.test.ts +6 -6
  106. package/test/variable-measure-rcn.test.ts +63 -68
  107. package/test/verified-by-gs1.test.ts +55 -0
  108. package/tsconfig-src.json +7 -1
  109. package/tsconfig-src.tsbuildinfo +1 -0
  110. package/tsconfig-tsup.json +7 -0
@@ -0,0 +1,30 @@
1
+ import {
2
+ type GTINBaseLength,
3
+ GTINLengths,
4
+ type GTINValidator,
5
+ IdentifierTypes,
6
+ LeaderTypes,
7
+ type PrefixType,
8
+ PrefixTypes
9
+ } from "../src/index.js";
10
+ import { validateNumericIdentifierValidator } from "./numeric-identifier-validator.js";
11
+
12
+ export function validateGTINValidator(validator: GTINValidator, isCreator: boolean, gtinBaseLength: GTINBaseLength): void {
13
+ let prefixType: PrefixType;
14
+
15
+ switch (gtinBaseLength) {
16
+ case GTINLengths.GTIN13:
17
+ prefixType = PrefixTypes.GS1CompanyPrefix;
18
+ break;
19
+
20
+ case GTINLengths.GTIN12:
21
+ prefixType = PrefixTypes.UPCCompanyPrefix;
22
+ break;
23
+
24
+ case GTINLengths.GTIN8:
25
+ prefixType = PrefixTypes.GS18Prefix;
26
+ break;
27
+ }
28
+
29
+ validateNumericIdentifierValidator(validator, IdentifierTypes.GTIN, prefixType, gtinBaseLength, LeaderTypes.IndicatorDigit);
30
+ }
@@ -8,9 +8,9 @@ import {
8
8
  type PrefixManager,
9
9
  PrefixTypes
10
10
  } from "../src/index.js";
11
- import { validateGTINValidator } from "./gtin-validator.test.js";
12
- import { validateNonGTINNumericIdentifierValidator } from "./non-gtin-numeric-identifier-validator.js";
11
+ import { validateGTINValidator } from "./gtin-validator.js";
13
12
  import { validateNonNumericIdentifierValidator } from "./non-numeric-identifier-validator.js";
13
+ import { validateNonSerializableNumericIdentifierValidator } from "./non-serializable-numeric-identifier-validator.js";
14
14
  import { validateSerializableNumericIdentifierValidator } from "./serializable-numeric-identifier-validator.js";
15
15
 
16
16
  export function validateIdentifierCreators(prefixManager: PrefixManager): void {
@@ -52,14 +52,14 @@ export function validateIdentifierCreators(prefixManager: PrefixManager): void {
52
52
  expect(prefixManager.cpidCreator).toBe(prefixManager.cpidCreator);
53
53
  expect(prefixManager.gmnCreator).toBe(prefixManager.gmnCreator);
54
54
 
55
- validateNonGTINNumericIdentifierValidator(prefixManager.glnCreator, true, IdentifierTypes.GLN, 13, LeaderTypes.None);
56
- validateNonGTINNumericIdentifierValidator(prefixManager.ssccCreator, true, IdentifierTypes.SSCC, 18, LeaderTypes.ExtensionDigit);
55
+ validateNonSerializableNumericIdentifierValidator(prefixManager.glnCreator, true, IdentifierTypes.GLN, 13, LeaderTypes.None);
56
+ validateNonSerializableNumericIdentifierValidator(prefixManager.ssccCreator, true, IdentifierTypes.SSCC, 18, LeaderTypes.ExtensionDigit);
57
57
  validateSerializableNumericIdentifierValidator(prefixManager.graiCreator, true, IdentifierTypes.GRAI, 13, LeaderTypes.None, 16, ContentCharacterSets.AI82);
58
58
  validateNonNumericIdentifierValidator(prefixManager.giaiCreator, true, IdentifierTypes.GIAI, 30, ContentCharacterSets.AI82, false);
59
- validateNonGTINNumericIdentifierValidator(prefixManager.gsrnCreator, true, IdentifierTypes.GSRN, 18, LeaderTypes.None);
59
+ validateNonSerializableNumericIdentifierValidator(prefixManager.gsrnCreator, true, IdentifierTypes.GSRN, 18, LeaderTypes.None);
60
60
  validateSerializableNumericIdentifierValidator(prefixManager.gdtiCreator, true, IdentifierTypes.GDTI, 13, LeaderTypes.None, 17, ContentCharacterSets.AI82);
61
61
  validateNonNumericIdentifierValidator(prefixManager.gincCreator, true, IdentifierTypes.GINC, 30, ContentCharacterSets.AI82, false);
62
- validateNonGTINNumericIdentifierValidator(prefixManager.gsinCreator, true, IdentifierTypes.GSIN, 17, LeaderTypes.None);
62
+ validateNonSerializableNumericIdentifierValidator(prefixManager.gsinCreator, true, IdentifierTypes.GSIN, 17, LeaderTypes.None);
63
63
  validateSerializableNumericIdentifierValidator(prefixManager.gcnCreator, true, IdentifierTypes.GCN, 13, LeaderTypes.None, 12, ContentCharacterSets.Numeric);
64
64
  validateNonNumericIdentifierValidator(prefixManager.cpidCreator, true, IdentifierTypes.CPID, 30, ContentCharacterSets.AI39, false);
65
65
  validateNonNumericIdentifierValidator(prefixManager.gmnCreator, true, IdentifierTypes.GMN, 25, ContentCharacterSets.AI82, true);
@@ -68,14 +68,6 @@ export function testNonNumericIdentifierCreator(creator: NonNumericIdentifierCre
68
68
  expect(index).toBe(referenceCount);
69
69
  });
70
70
 
71
- test("Position offset", () => {
72
- expect(() => {
73
- creator.validate(creator.create("ABC123"), {
74
- positionOffset: 4
75
- });
76
- }).not.toThrow(RangeError);
77
- });
78
-
79
71
  test("Not all numeric", () => {
80
72
  expect(() => {
81
73
  creator.validate(creator.create("01234"), {
@@ -1,64 +1,14 @@
1
1
  import { expect, test } from "vitest";
2
2
  import {
3
- ContentCharacterSets,
4
- isSerializableNumericIdentifierCreator,
5
- type SerializableNumericIdentifierCreator
3
+ isNonSerializableNumericIdentifierCreator,
4
+ type NonSerializableNumericIdentifierCreator
6
5
  } from "../src/index.js";
7
6
  import { testNonGTINNumericIdentifierCreator } from "./non-gtin-numeric-identifier-creator.js";
8
7
 
9
- export function testSerializableNumericIdentifierCreator(creator: SerializableNumericIdentifierCreator): void {
8
+ export function testNonSerializableNumericIdentifierCreator(creator: NonSerializableNumericIdentifierCreator): void {
10
9
  testNonGTINNumericIdentifierCreator(creator, () => {
11
10
  test("Mapping", () => {
12
- expect(isSerializableNumericIdentifierCreator(creator)).toBe(true);
13
- });
14
- }, () => {
15
- test("Serialization", () => {
16
- const identifier = creator.create(0, true);
17
- const serial = "12345678";
18
- const serializedIdentifier = identifier + serial;
19
- const serials = [serial, "23456789", "34567890", "456789012"];
20
- const serializedIdentifiers = serials.map(serial => identifier + serial);
21
-
22
- expect(creator.createSerialized(0, serial, true)).toBe(serializedIdentifier);
23
- expect(creator.concatenate(identifier, serial)).toBe(serializedIdentifier);
24
- expect(Array.from(creator.createSerialized(0, serials, true))).toStrictEqual(serializedIdentifiers);
25
- expect(Array.from(creator.concatenate(identifier, serials))).toStrictEqual(serializedIdentifiers);
26
-
27
- const fullLengthSerial = "0".repeat(creator.serialComponentLength);
28
- const fullLengthPlusOneSerial = fullLengthSerial + "0";
29
- const fullLengthPlusOneSerialErrorMessage = `Length ${creator.serialComponentLength + 1} of serial component must be less than or equal to ${creator.serialComponentLength}`;
30
-
31
- expect(() => creator.createSerialized(0, fullLengthSerial, true)).not.toThrow(RangeError);
32
- expect(() => creator.concatenate(identifier, fullLengthSerial)).not.toThrow(RangeError);
33
- expect(() => Array.from(creator.createSerialized(0, [...serials, fullLengthSerial], true))).not.toThrow(RangeError);
34
- expect(() => Array.from(creator.concatenate(identifier, [...serials, fullLengthSerial]))).not.toThrow(RangeError);
35
- expect(() => creator.createSerialized(0, fullLengthPlusOneSerial, true)).toThrow(fullLengthPlusOneSerialErrorMessage);
36
- expect(() => creator.concatenate(identifier, fullLengthPlusOneSerial)).toThrow(fullLengthPlusOneSerialErrorMessage);
37
- expect(() => Array.from(creator.createSerialized(0, [...serials, fullLengthPlusOneSerial], true))).toThrow(fullLengthPlusOneSerialErrorMessage);
38
- expect(() => Array.from(creator.concatenate(identifier, [...serials, fullLengthPlusOneSerial]))).toThrow(fullLengthPlusOneSerialErrorMessage);
39
-
40
- let invalidSerial: string;
41
-
42
- switch (creator.serialComponentCharacterSet) {
43
- case ContentCharacterSets.Numeric:
44
- invalidSerial = "1234A5678";
45
- break;
46
-
47
- case ContentCharacterSets.AI82:
48
- invalidSerial = "ABCD~1234";
49
- break;
50
-
51
- case ContentCharacterSets.AI39:
52
- invalidSerial = "ABCD%1234";
53
- break;
54
- }
55
-
56
- const invalidSerialErrorMessage = `Invalid character '${invalidSerial.charAt(4)}' at position 5 of serial component`;
57
-
58
- expect(() => creator.createSerialized(0, invalidSerial, true)).toThrow(invalidSerialErrorMessage);
59
- expect(() => creator.concatenate(identifier, invalidSerial)).toThrow(invalidSerialErrorMessage);
60
- expect(() => Array.from(creator.createSerialized(0, [...serials, invalidSerial], true))).toThrow(invalidSerialErrorMessage);
61
- expect(() => Array.from(creator.concatenate(identifier, [...serials, invalidSerial]))).toThrow(invalidSerialErrorMessage);
11
+ expect(isNonSerializableNumericIdentifierCreator(creator)).toBe(true);
62
12
  });
63
13
  });
64
14
  }
@@ -62,8 +62,8 @@ export function testNumericIdentifierCreator<TNumericIdentifierType extends Nume
62
62
  expect(index).toBe(referenceCount);
63
63
  expect(sequenceIterator.next().value).toBeUndefined();
64
64
 
65
- const randomValues = new Array<number>();
66
- const identifiers = new Array<string>();
65
+ const randomValues: number[] = [];
66
+ const identifiers: string[] = [];
67
67
 
68
68
  for (let i = 0; i < 1000; i++) {
69
69
  const randomValue = Math.floor(Math.random() * creator.capacity);
@@ -99,8 +99,8 @@ export function testNumericIdentifierCreator<TNumericIdentifierType extends Nume
99
99
  expect(sequential).toBe(false);
100
100
  expect(index).toBe(sparseReferenceCount);
101
101
 
102
- const randomValues = new Array<number>();
103
- const identifiers = new Array<string>();
102
+ const randomValues: number[] = [];
103
+ const identifiers: string[] = [];
104
104
 
105
105
  for (let i = 0; i < 1000; i++) {
106
106
  const randomValue = Math.floor(Math.random() * creator.capacity);
@@ -15,7 +15,7 @@ describe("Prefix manager", () => {
15
15
 
16
16
  const gtin14 = prefixManager.gtinCreator.createGTIN14("5", 0);
17
17
 
18
- expect(gtin14.startsWith("5" + prefixManager.gs1CompanyPrefix)).toBe(true);
18
+ expect(gtin14.startsWith(`5${prefixManager.gs1CompanyPrefix}`)).toBe(true);
19
19
  expect(gtin14.length).toBe(14);
20
20
  }
21
21
 
@@ -64,7 +64,7 @@ describe("Prefix manager", () => {
64
64
 
65
65
  expect(prefixManager.prefixType).toBe(PrefixTypes.UPCCompanyPrefix);
66
66
  expect(prefixManager.prefix).toBe("614141");
67
- expect(prefixManager.gs1CompanyPrefix).toBe("0" + prefixManager.prefix);
67
+ expect(prefixManager.gs1CompanyPrefix).toBe(`0${prefixManager.prefix}`);
68
68
  expect(prefixManager.upcCompanyPrefix).toBe(prefixManager.prefix);
69
69
  expect(prefixManager.gs18Prefix).toBeUndefined();
70
70
 
@@ -79,7 +79,7 @@ describe("Prefix manager", () => {
79
79
 
80
80
  expect(prefixManager.prefixType).toBe(PrefixTypes.GS18Prefix);
81
81
  expect(prefixManager.prefix).toBe("952");
82
- expect(prefixManager.gs1CompanyPrefix).toBe("00000" + prefixManager.prefix);
82
+ expect(prefixManager.gs1CompanyPrefix).toBe(`00000${prefixManager.prefix}`);
83
83
  expect(prefixManager.upcCompanyPrefix).toBeUndefined();
84
84
  expect(prefixManager.gs18Prefix).toBe(prefixManager.prefix);
85
85
 
@@ -96,8 +96,8 @@ describe("Prefix manager", () => {
96
96
 
97
97
  expect(() => PrefixManager.get(PrefixTypes.GS1CompanyPrefix, "952123A56789")).toThrow("Invalid character 'A' at position 7 of GS1 Company Prefix");
98
98
 
99
- expect(() => PrefixManager.get(PrefixTypes.UPCCompanyPrefix, "61414")).toThrow("Length 5 of U.P.C. Company Prefix must be greater than or equal to 6");
100
- expect(() => PrefixManager.get(PrefixTypes.UPCCompanyPrefix, "614141")).not.toThrow(RangeError);
99
+ expect(() => PrefixManager.get(PrefixTypes.UPCCompanyPrefix, "6141")).toThrow("Length 4 of U.P.C. Company Prefix must be greater than or equal to 5");
100
+ expect(() => PrefixManager.get(PrefixTypes.UPCCompanyPrefix, "61414")).not.toThrow(RangeError);
101
101
  expect(() => PrefixManager.get(PrefixTypes.UPCCompanyPrefix, "61414112345")).not.toThrow(RangeError);
102
102
  expect(() => PrefixManager.get(PrefixTypes.UPCCompanyPrefix, "614141123456")).toThrow("Length 12 of U.P.C. Company Prefix must be less than or equal to 11");
103
103
  expect(() => PrefixManager.get(PrefixTypes.UPCCompanyPrefix, "000614")).not.toThrow(RangeError);
@@ -13,29 +13,42 @@ export function testSerializableNumericIdentifierCreator(creator: SerializableNu
13
13
  });
14
14
  }, () => {
15
15
  test("Serialization", () => {
16
- const identifier = creator.create(0, true);
17
- const serial = "12345678";
18
- const serializedIdentifier = identifier + serial;
19
- const serials = [serial, "23456789", "34567890", "456789012"];
20
- const serializedIdentifiers = serials.map(serial => identifier + serial);
16
+ const baseIdentifier = creator.create(0, true);
17
+ const serialComponent = "12345678";
18
+ const serializedIdentifier = baseIdentifier + serialComponent;
19
+ const serialComponents = [serialComponent, "23456789", "34567890", "456789012"];
20
+ const serializedIdentifiers = serialComponents.map(serial => baseIdentifier + serial);
21
21
 
22
- expect(creator.createSerialized(0, serial, true)).toBe(serializedIdentifier);
23
- expect(creator.concatenate(identifier, serial)).toBe(serializedIdentifier);
24
- expect(Array.from(creator.createSerialized(0, serials, true))).toStrictEqual(serializedIdentifiers);
25
- expect(Array.from(creator.concatenate(identifier, serials))).toStrictEqual(serializedIdentifiers);
22
+ expect(creator.split(baseIdentifier)).toStrictEqual({
23
+ baseIdentifier,
24
+ serialComponent: ""
25
+ });
26
+
27
+ expect(creator.createSerialized(0, serialComponent, true)).toBe(serializedIdentifier);
28
+ expect(creator.split(creator.createSerialized(0, serialComponent, true))).toStrictEqual({
29
+ baseIdentifier,
30
+ serialComponent
31
+ });
32
+ expect(creator.concatenate(baseIdentifier, serialComponent)).toBe(serializedIdentifier);
33
+ expect(creator.split(creator.concatenate(baseIdentifier, serialComponent))).toStrictEqual({
34
+ baseIdentifier,
35
+ serialComponent
36
+ });
37
+ expect(Array.from(creator.createSerialized(0, serialComponents, true))).toStrictEqual(serializedIdentifiers);
38
+ expect(Array.from(creator.concatenate(baseIdentifier, serialComponents))).toStrictEqual(serializedIdentifiers);
26
39
 
27
40
  const fullLengthSerial = "0".repeat(creator.serialComponentLength);
28
- const fullLengthPlusOneSerial = fullLengthSerial + "0";
41
+ const fullLengthPlusOneSerial = `${fullLengthSerial}0`;
29
42
  const fullLengthPlusOneSerialErrorMessage = `Length ${creator.serialComponentLength + 1} of serial component must be less than or equal to ${creator.serialComponentLength}`;
30
43
 
31
44
  expect(() => creator.createSerialized(0, fullLengthSerial, true)).not.toThrow(RangeError);
32
- expect(() => creator.concatenate(identifier, fullLengthSerial)).not.toThrow(RangeError);
33
- expect(() => Array.from(creator.createSerialized(0, [...serials, fullLengthSerial], true))).not.toThrow(RangeError);
34
- expect(() => Array.from(creator.concatenate(identifier, [...serials, fullLengthSerial]))).not.toThrow(RangeError);
45
+ expect(() => creator.concatenate(baseIdentifier, fullLengthSerial)).not.toThrow(RangeError);
46
+ expect(() => Array.from(creator.createSerialized(0, [...serialComponents, fullLengthSerial], true))).not.toThrow(RangeError);
47
+ expect(() => Array.from(creator.concatenate(baseIdentifier, [...serialComponents, fullLengthSerial]))).not.toThrow(RangeError);
35
48
  expect(() => creator.createSerialized(0, fullLengthPlusOneSerial, true)).toThrow(fullLengthPlusOneSerialErrorMessage);
36
- expect(() => creator.concatenate(identifier, fullLengthPlusOneSerial)).toThrow(fullLengthPlusOneSerialErrorMessage);
37
- expect(() => Array.from(creator.createSerialized(0, [...serials, fullLengthPlusOneSerial], true))).toThrow(fullLengthPlusOneSerialErrorMessage);
38
- expect(() => Array.from(creator.concatenate(identifier, [...serials, fullLengthPlusOneSerial]))).toThrow(fullLengthPlusOneSerialErrorMessage);
49
+ expect(() => creator.concatenate(baseIdentifier, fullLengthPlusOneSerial)).toThrow(fullLengthPlusOneSerialErrorMessage);
50
+ expect(() => Array.from(creator.createSerialized(0, [...serialComponents, fullLengthPlusOneSerial], true))).toThrow(fullLengthPlusOneSerialErrorMessage);
51
+ expect(() => Array.from(creator.concatenate(baseIdentifier, [...serialComponents, fullLengthPlusOneSerial]))).toThrow(fullLengthPlusOneSerialErrorMessage);
39
52
 
40
53
  let invalidSerial: string;
41
54
 
@@ -56,9 +69,9 @@ export function testSerializableNumericIdentifierCreator(creator: SerializableNu
56
69
  const invalidSerialErrorMessage = `Invalid character '${invalidSerial.charAt(4)}' at position 5 of serial component`;
57
70
 
58
71
  expect(() => creator.createSerialized(0, invalidSerial, true)).toThrow(invalidSerialErrorMessage);
59
- expect(() => creator.concatenate(identifier, invalidSerial)).toThrow(invalidSerialErrorMessage);
60
- expect(() => Array.from(creator.createSerialized(0, [...serials, invalidSerial], true))).toThrow(invalidSerialErrorMessage);
61
- expect(() => Array.from(creator.concatenate(identifier, [...serials, invalidSerial]))).toThrow(invalidSerialErrorMessage);
72
+ expect(() => creator.concatenate(baseIdentifier, invalidSerial)).toThrow(invalidSerialErrorMessage);
73
+ expect(() => Array.from(creator.createSerialized(0, [...serialComponents, invalidSerial], true))).toThrow(invalidSerialErrorMessage);
74
+ expect(() => Array.from(creator.concatenate(baseIdentifier, [...serialComponents, invalidSerial]))).toThrow(invalidSerialErrorMessage);
62
75
  });
63
76
  });
64
77
  }
@@ -17,9 +17,9 @@ import {
17
17
  isSerializableNumericIdentifierValidator,
18
18
  LeaderTypes
19
19
  } from "../src/index.js";
20
- import { validateGTINValidator } from "./gtin-validator.test.js";
21
- import { validateNonGTINNumericIdentifierValidator } from "./non-gtin-numeric-identifier-validator.js";
20
+ import { validateGTINValidator } from "./gtin-validator.js";
22
21
  import { validateNonNumericIdentifierValidator } from "./non-numeric-identifier-validator.js";
22
+ import { validateNonSerializableNumericIdentifierValidator } from "./non-serializable-numeric-identifier-validator.js";
23
23
  import { validateSerializableNumericIdentifierValidator } from "./serializable-numeric-identifier-validator.js";
24
24
 
25
25
  describe("Validators", () => {
@@ -62,14 +62,14 @@ describe("Validators", () => {
62
62
  validateGTINValidator(IdentifierValidators.GTIN[GTINLengths.GTIN13], false, GTINLengths.GTIN13);
63
63
  validateGTINValidator(IdentifierValidators.GTIN[GTINLengths.GTIN12], false, GTINLengths.GTIN12);
64
64
  validateGTINValidator(IdentifierValidators.GTIN[GTINLengths.GTIN8], false, GTINLengths.GTIN8);
65
- validateNonGTINNumericIdentifierValidator(IdentifierValidators.GLN, false, IdentifierTypes.GLN, 13, LeaderTypes.None);
66
- validateNonGTINNumericIdentifierValidator(IdentifierValidators.SSCC, false, IdentifierTypes.SSCC, 18, LeaderTypes.ExtensionDigit);
65
+ validateNonSerializableNumericIdentifierValidator(IdentifierValidators.GLN, false, IdentifierTypes.GLN, 13, LeaderTypes.None);
66
+ validateNonSerializableNumericIdentifierValidator(IdentifierValidators.SSCC, false, IdentifierTypes.SSCC, 18, LeaderTypes.ExtensionDigit);
67
67
  validateSerializableNumericIdentifierValidator(IdentifierValidators.GRAI, false, IdentifierTypes.GRAI, 13, LeaderTypes.None, 16, ContentCharacterSets.AI82);
68
68
  validateNonNumericIdentifierValidator(IdentifierValidators.GIAI, false, IdentifierTypes.GIAI, 30, ContentCharacterSets.AI82, false);
69
- validateNonGTINNumericIdentifierValidator(IdentifierValidators.GSRN, false, IdentifierTypes.GSRN, 18, LeaderTypes.None);
69
+ validateNonSerializableNumericIdentifierValidator(IdentifierValidators.GSRN, false, IdentifierTypes.GSRN, 18, LeaderTypes.None);
70
70
  validateSerializableNumericIdentifierValidator(IdentifierValidators.GDTI, false, IdentifierTypes.GDTI, 13, LeaderTypes.None, 17, ContentCharacterSets.AI82);
71
71
  validateNonNumericIdentifierValidator(IdentifierValidators.GINC, false, IdentifierTypes.GINC, 30, ContentCharacterSets.AI82, false);
72
- validateNonGTINNumericIdentifierValidator(IdentifierValidators.GSIN, false, IdentifierTypes.GSIN, 17, LeaderTypes.None);
72
+ validateNonSerializableNumericIdentifierValidator(IdentifierValidators.GSIN, false, IdentifierTypes.GSIN, 17, LeaderTypes.None);
73
73
  validateSerializableNumericIdentifierValidator(IdentifierValidators.GCN, false, IdentifierTypes.GCN, 13, LeaderTypes.None, 12, ContentCharacterSets.Numeric);
74
74
  validateNonNumericIdentifierValidator(IdentifierValidators.CPID, false, IdentifierTypes.CPID, 30, ContentCharacterSets.AI39, false);
75
75
  validateNonNumericIdentifierValidator(IdentifierValidators.GMN, false, IdentifierTypes.GMN, 25, ContentCharacterSets.AI82, true);
@@ -1,15 +1,10 @@
1
1
  import { describe, expect, test } from "vitest";
2
- import {
3
- GTINCreator,
4
- GTINValidator,
5
- hasValidCheckDigit,
6
- isValidPriceOrWeightCheckDigit,
7
- type RCNReference
8
- } from "../src/index.js";
2
+ import { hasValidCheckDigit, isValidPriceOrWeightCheckDigit, type RCNReference } from "../src/index.js";
3
+ import { VariableMeasure } from "../src/index.js";
9
4
 
10
5
  describe("Variable measure RCN", () => {
11
6
  test("RCN-12", () => {
12
- const rcn1 = GTINCreator.createVariableMeasureRCN("2IIIIIVPPPPC", 12345, 4321);
7
+ const rcn1 = VariableMeasure.createRCN("2IIIIIVPPPPC", 12345, 4321);
13
8
 
14
9
  expect(rcn1.length).toBe(12);
15
10
  expect(rcn1.charAt(0)).toBe("2");
@@ -18,14 +13,14 @@ describe("Variable measure RCN", () => {
18
13
  expect(isValidPriceOrWeightCheckDigit(rcn1.substring(7, 11), rcn1.charAt(6))).toBe(true);
19
14
  expect(hasValidCheckDigit(rcn1)).toBe(true);
20
15
  expect(() => {
21
- GTINValidator.parseVariableMeasureRCN("2IIIIIVPPPPC", rcn1);
16
+ VariableMeasure.parseRCN("2IIIIIVPPPPC", rcn1);
22
17
  }).not.toThrow(RangeError);
23
- expect(GTINValidator.parseVariableMeasureRCN("2IIIIIVPPPPC", rcn1)).toEqual({
18
+ expect(VariableMeasure.parseRCN("2IIIIIVPPPPC", rcn1)).toEqual({
24
19
  itemReference: 12345,
25
20
  priceOrWeight: 4321
26
21
  } satisfies RCNReference);
27
22
 
28
- const rcn2 = GTINCreator.createVariableMeasureRCN("2IIIIPPPPPVC", 1234, 54321);
23
+ const rcn2 = VariableMeasure.createRCN("2IIIIPPPPPVC", 1234, 54321);
29
24
 
30
25
  expect(rcn2.length).toBe(12);
31
26
  expect(rcn2.charAt(0)).toBe("2");
@@ -34,14 +29,14 @@ describe("Variable measure RCN", () => {
34
29
  expect(isValidPriceOrWeightCheckDigit(rcn2.substring(5, 10), rcn2.charAt(10))).toBe(true);
35
30
  expect(hasValidCheckDigit(rcn2)).toBe(true);
36
31
  expect(() => {
37
- GTINValidator.parseVariableMeasureRCN("2IIIIPPPPPVC", rcn2);
32
+ VariableMeasure.parseRCN("2IIIIPPPPPVC", rcn2);
38
33
  }).not.toThrow(RangeError);
39
- expect(GTINValidator.parseVariableMeasureRCN("2IIIIPPPPPVC", rcn2)).toEqual({
34
+ expect(VariableMeasure.parseRCN("2IIIIPPPPPVC", rcn2)).toEqual({
40
35
  itemReference: 1234,
41
36
  priceOrWeight: 54321
42
37
  } satisfies RCNReference);
43
38
 
44
- const rcn3 = GTINCreator.createVariableMeasureRCN("2PPPPPIIIIIC", 12345, 54321);
39
+ const rcn3 = VariableMeasure.createRCN("2PPPPPIIIIIC", 12345, 54321);
45
40
 
46
41
  expect(rcn3.length).toBe(12);
47
42
  expect(rcn3.charAt(0)).toBe("2");
@@ -49,64 +44,64 @@ describe("Variable measure RCN", () => {
49
44
  expect(rcn3.substring(6, 11)).toBe("12345");
50
45
  expect(hasValidCheckDigit(rcn3)).toBe(true);
51
46
  expect(() => {
52
- GTINValidator.parseVariableMeasureRCN("2PPPPPIIIIIC", rcn3);
47
+ VariableMeasure.parseRCN("2PPPPPIIIIIC", rcn3);
53
48
  }).not.toThrow(RangeError);
54
- expect(GTINValidator.parseVariableMeasureRCN("2PPPPPIIIIIC", rcn3)).toEqual({
49
+ expect(VariableMeasure.parseRCN("2PPPPPIIIIIC", rcn3)).toEqual({
55
50
  itemReference: 12345,
56
51
  priceOrWeight: 54321
57
52
  } satisfies RCNReference);
58
53
 
59
- expect(() => GTINCreator.createVariableMeasureRCN("3PPPPPIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
60
- expect(() => GTINCreator.createVariableMeasureRCN("20PPPPPIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
61
- expect(() => GTINCreator.createVariableMeasureRCN("2PPPPPIIIIII", 12345, 54321)).toThrow("Invalid variable measure RCN format");
62
- expect(() => GTINCreator.createVariableMeasureRCN("2PPPPPIIIIKC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
63
- expect(() => GTINCreator.createVariableMeasureRCN("2PPPPPIIPIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
64
- expect(() => GTINCreator.createVariableMeasureRCN("2PPIPPIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
65
- expect(() => GTINCreator.createVariableMeasureRCN("2PPPPPIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
66
- expect(() => GTINCreator.createVariableMeasureRCN("2PPPPPIIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
67
- expect(() => GTINCreator.createVariableMeasureRCN("2PPPPPPPPPPC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
68
- expect(() => GTINCreator.createVariableMeasureRCN("2IIIIIIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
54
+ expect(() => VariableMeasure.createRCN("3PPPPPIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
55
+ expect(() => VariableMeasure.createRCN("20PPPPPIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
56
+ expect(() => VariableMeasure.createRCN("2PPPPPIIIIII", 12345, 54321)).toThrow("Invalid variable measure RCN format");
57
+ expect(() => VariableMeasure.createRCN("2PPPPPIIIIKC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
58
+ expect(() => VariableMeasure.createRCN("2PPPPPIIPIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
59
+ expect(() => VariableMeasure.createRCN("2PPIPPIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
60
+ expect(() => VariableMeasure.createRCN("2PPPPPIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
61
+ expect(() => VariableMeasure.createRCN("2PPPPPIIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
62
+ expect(() => VariableMeasure.createRCN("2PPPPPPPPPPC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
63
+ expect(() => VariableMeasure.createRCN("2IIIIIIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
69
64
 
70
65
  expect(() => {
71
- GTINValidator.parseVariableMeasureRCN("3PPPPPIIIIIC", "2543211234540");
66
+ VariableMeasure.parseRCN("3PPPPPIIIIIC", "2543211234540");
72
67
  }).toThrow("RCN length must match format length");
73
68
  expect(() => {
74
- GTINValidator.parseVariableMeasureRCN("3PPPPPIIIIIC", "25432112345");
69
+ VariableMeasure.parseRCN("3PPPPPIIIIIC", "25432112345");
75
70
  }).toThrow("RCN length must match format length");
76
71
  expect(() => {
77
- GTINValidator.parseVariableMeasureRCN("3PPPPPIIIIIC", "254321123454");
72
+ VariableMeasure.parseRCN("3PPPPPIIIIIC", "254321123454");
78
73
  }).toThrow("Invalid variable measure RCN format");
79
74
  expect(() => {
80
- GTINValidator.parseVariableMeasureRCN("20PPPPPIIIIC", "254321123454");
75
+ VariableMeasure.parseRCN("20PPPPPIIIIC", "254321123454");
81
76
  }).toThrow("Invalid variable measure RCN format");
82
77
  expect(() => {
83
- GTINValidator.parseVariableMeasureRCN("2PPPPPIIIIII", "254321123454");
78
+ VariableMeasure.parseRCN("2PPPPPIIIIII", "254321123454");
84
79
  }).toThrow("Invalid variable measure RCN format");
85
80
  expect(() => {
86
- GTINValidator.parseVariableMeasureRCN("2PPPPPIIIIKC", "254321123454");
81
+ VariableMeasure.parseRCN("2PPPPPIIIIKC", "254321123454");
87
82
  }).toThrow("Invalid variable measure RCN format");
88
83
  expect(() => {
89
- GTINValidator.parseVariableMeasureRCN("2PPPPPIIPIIC", "254321123454");
84
+ VariableMeasure.parseRCN("2PPPPPIIPIIC", "254321123454");
90
85
  }).toThrow("Invalid variable measure RCN format");
91
86
  expect(() => {
92
- GTINValidator.parseVariableMeasureRCN("2PPIPPIIIIIC", "254321123454");
87
+ VariableMeasure.parseRCN("2PPIPPIIIIIC", "254321123454");
93
88
  }).toThrow("Invalid variable measure RCN format");
94
89
  expect(() => {
95
- GTINValidator.parseVariableMeasureRCN("2PPPPPIIIIC", "25432112345");
90
+ VariableMeasure.parseRCN("2PPPPPIIIIC", "25432112345");
96
91
  }).toThrow("Invalid variable measure RCN format");
97
92
  expect(() => {
98
- GTINValidator.parseVariableMeasureRCN("2PPPPPIIIIIIC", "2543211234540");
93
+ VariableMeasure.parseRCN("2PPPPPIIIIIIC", "2543211234540");
99
94
  }).toThrow("Invalid variable measure RCN format");
100
95
  expect(() => {
101
- GTINValidator.parseVariableMeasureRCN("2PPPPPPPPPPC", "254321123454");
96
+ VariableMeasure.parseRCN("2PPPPPPPPPPC", "254321123454");
102
97
  }).toThrow("Invalid variable measure RCN format");
103
98
  expect(() => {
104
- GTINValidator.parseVariableMeasureRCN("2IIIIIIIIIIC", "254321123454");
99
+ VariableMeasure.parseRCN("2IIIIIIIIIIC", "254321123454");
105
100
  }).toThrow("Invalid variable measure RCN format");
106
101
  });
107
102
 
108
103
  test("RCN-13", () => {
109
- const rcn1 = GTINCreator.createVariableMeasureRCN("24IIIIIVPPPPC", 12345, 4321);
104
+ const rcn1 = VariableMeasure.createRCN("24IIIIIVPPPPC", 12345, 4321);
110
105
 
111
106
  expect(rcn1.length).toBe(13);
112
107
  expect(rcn1.substring(0, 2)).toBe("24");
@@ -115,14 +110,14 @@ describe("Variable measure RCN", () => {
115
110
  expect(isValidPriceOrWeightCheckDigit(rcn1.substring(8, 12), rcn1.charAt(7))).toBe(true);
116
111
  expect(hasValidCheckDigit(rcn1)).toBe(true);
117
112
  expect(() => {
118
- GTINValidator.parseVariableMeasureRCN("24IIIIIVPPPPC", rcn1);
113
+ VariableMeasure.parseRCN("24IIIIIVPPPPC", rcn1);
119
114
  }).not.toThrow(RangeError);
120
- expect(GTINValidator.parseVariableMeasureRCN("24IIIIIVPPPPC", rcn1)).toEqual({
115
+ expect(VariableMeasure.parseRCN("24IIIIIVPPPPC", rcn1)).toEqual({
121
116
  itemReference: 12345,
122
117
  priceOrWeight: 4321
123
118
  } satisfies RCNReference);
124
119
 
125
- const rcn2 = GTINCreator.createVariableMeasureRCN("21IIIIPPPPPVC", 1234, 54321);
120
+ const rcn2 = VariableMeasure.createRCN("21IIIIPPPPPVC", 1234, 54321);
126
121
 
127
122
  expect(rcn2.length).toBe(13);
128
123
  expect(rcn2.substring(0, 2)).toBe("21");
@@ -131,14 +126,14 @@ describe("Variable measure RCN", () => {
131
126
  expect(isValidPriceOrWeightCheckDigit(rcn2.substring(6, 11), rcn2.charAt(11))).toBe(true);
132
127
  expect(hasValidCheckDigit(rcn2)).toBe(true);
133
128
  expect(() => {
134
- GTINValidator.parseVariableMeasureRCN("21IIIIPPPPPVC", rcn2);
129
+ VariableMeasure.parseRCN("21IIIIPPPPPVC", rcn2);
135
130
  }).not.toThrow(RangeError);
136
- expect(GTINValidator.parseVariableMeasureRCN("21IIIIPPPPPVC", rcn2)).toEqual({
131
+ expect(VariableMeasure.parseRCN("21IIIIPPPPPVC", rcn2)).toEqual({
137
132
  itemReference: 1234,
138
133
  priceOrWeight: 54321
139
134
  } satisfies RCNReference);
140
135
 
141
- const rcn3 = GTINCreator.createVariableMeasureRCN("27PPPPPIIIIIC", 12345, 54321);
136
+ const rcn3 = VariableMeasure.createRCN("27PPPPPIIIIIC", 12345, 54321);
142
137
 
143
138
  expect(rcn3.length).toBe(13);
144
139
  expect(rcn3.substring(0, 2)).toBe("27");
@@ -146,56 +141,56 @@ describe("Variable measure RCN", () => {
146
141
  expect(rcn3.substring(7, 12)).toBe("12345");
147
142
  expect(hasValidCheckDigit(rcn3)).toBe(true);
148
143
  expect(() => {
149
- GTINValidator.parseVariableMeasureRCN("27PPPPPIIIIIC", rcn3);
144
+ VariableMeasure.parseRCN("27PPPPPIIIIIC", rcn3);
150
145
  }).not.toThrow(RangeError);
151
- expect(GTINValidator.parseVariableMeasureRCN("27PPPPPIIIIIC", rcn3)).toEqual({
146
+ expect(VariableMeasure.parseRCN("27PPPPPIIIIIC", rcn3)).toEqual({
152
147
  itemReference: 12345,
153
148
  priceOrWeight: 54321
154
149
  } satisfies RCNReference);
155
150
 
156
- expect(() => GTINCreator.createVariableMeasureRCN("30PPPPPIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
157
- expect(() => GTINCreator.createVariableMeasureRCN("2PPPPPPIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
158
- expect(() => GTINCreator.createVariableMeasureRCN("20PPPPPIIIIII", 12345, 54321)).toThrow("Invalid variable measure RCN format");
159
- expect(() => GTINCreator.createVariableMeasureRCN("21PPPPPIIIIKC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
160
- expect(() => GTINCreator.createVariableMeasureRCN("22PPPPPIIPIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
161
- expect(() => GTINCreator.createVariableMeasureRCN("23PPIPPIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
162
- expect(() => GTINCreator.createVariableMeasureRCN("24PPPPPIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
163
- expect(() => GTINCreator.createVariableMeasureRCN("25PPPPPIIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
164
- expect(() => GTINCreator.createVariableMeasureRCN("26PPPPPPPPPPC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
165
- expect(() => GTINCreator.createVariableMeasureRCN("27IIIIIIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
151
+ expect(() => VariableMeasure.createRCN("30PPPPPIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
152
+ expect(() => VariableMeasure.createRCN("2PPPPPPIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
153
+ expect(() => VariableMeasure.createRCN("20PPPPPIIIIII", 12345, 54321)).toThrow("Invalid variable measure RCN format");
154
+ expect(() => VariableMeasure.createRCN("21PPPPPIIIIKC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
155
+ expect(() => VariableMeasure.createRCN("22PPPPPIIPIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
156
+ expect(() => VariableMeasure.createRCN("23PPIPPIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
157
+ expect(() => VariableMeasure.createRCN("24PPPPPIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
158
+ expect(() => VariableMeasure.createRCN("25PPPPPIIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
159
+ expect(() => VariableMeasure.createRCN("26PPPPPPPPPPC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
160
+ expect(() => VariableMeasure.createRCN("27IIIIIIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
166
161
 
167
162
  expect(() => {
168
- GTINValidator.parseVariableMeasureRCN("30PPPPPIIIIIC", "27543211234570");
163
+ VariableMeasure.parseRCN("30PPPPPIIIIIC", "27543211234570");
169
164
  }).toThrow("RCN length must match format length");
170
165
  expect(() => {
171
- GTINValidator.parseVariableMeasureRCN("30PPPPPIIIIIC", "275432112345");
166
+ VariableMeasure.parseRCN("30PPPPPIIIIIC", "275432112345");
172
167
  }).toThrow("RCN length must match format length");
173
168
  expect(() => {
174
- GTINValidator.parseVariableMeasureRCN("30PPPPPIIIIIC", "2754321123457");
169
+ VariableMeasure.parseRCN("30PPPPPIIIIIC", "2754321123457");
175
170
  }).toThrow("Invalid variable measure RCN format");
176
171
  expect(() => {
177
- GTINValidator.parseVariableMeasureRCN("20PPPPPIIIIII", "2754321123457");
172
+ VariableMeasure.parseRCN("20PPPPPIIIIII", "2754321123457");
178
173
  }).toThrow("Invalid variable measure RCN format");
179
174
  expect(() => {
180
- GTINValidator.parseVariableMeasureRCN("21PPPPPIIIIKC", "2754321123457");
175
+ VariableMeasure.parseRCN("21PPPPPIIIIKC", "2754321123457");
181
176
  }).toThrow("Invalid variable measure RCN format");
182
177
  expect(() => {
183
- GTINValidator.parseVariableMeasureRCN("22PPPPPIIPIIC", "2754321123457");
178
+ VariableMeasure.parseRCN("22PPPPPIIPIIC", "2754321123457");
184
179
  }).toThrow("Invalid variable measure RCN format");
185
180
  expect(() => {
186
- GTINValidator.parseVariableMeasureRCN("23PPIPPIIIIIC", "2754321123457");
181
+ VariableMeasure.parseRCN("23PPIPPIIIIIC", "2754321123457");
187
182
  }).toThrow("Invalid variable measure RCN format");
188
183
  expect(() => {
189
- GTINValidator.parseVariableMeasureRCN("24PPPPPIIIIC", "275432112345");
184
+ VariableMeasure.parseRCN("24PPPPPIIIIC", "275432112345");
190
185
  }).toThrow("Invalid variable measure RCN format");
191
186
  expect(() => {
192
- GTINValidator.parseVariableMeasureRCN("25PPPPPIIIIIIC", "27543211234570");
187
+ VariableMeasure.parseRCN("25PPPPPIIIIIIC", "27543211234570");
193
188
  }).toThrow("Invalid variable measure RCN format");
194
189
  expect(() => {
195
- GTINValidator.parseVariableMeasureRCN("26PPPPPPPPPPC", "2754321123457");
190
+ VariableMeasure.parseRCN("26PPPPPPPPPPC", "2754321123457");
196
191
  }).toThrow("Invalid variable measure RCN format");
197
192
  expect(() => {
198
- GTINValidator.parseVariableMeasureRCN("27IIIIIIIIIIC", "2754321123457");
193
+ VariableMeasure.parseRCN("27IIIIIIIIIIC", "2754321123457");
199
194
  }).toThrow("Invalid variable measure RCN format");
200
195
  });
201
196
  });