gs1-validator
Reactive icon

Gs1 Validator

version 1.0.1 (Compatible with OutSystems 11)
Uploaded
 on 11 October 2024
 by 
5.0
 (1 rating)
gs1-validator

Gs1 Validator

Documentation
1.0.1

Consume the module dependency. After consume the module dependencies you can find

  • GTIN8_Validator
  • GTIN12_Validator
  • GTIN13_Validator
  • GTIN14_Validator

Once the things are doneyou can send the GS1 code and its type the logic will execute and give you the results.


1.0.0

GTIN Validator

GTIN (Global Trade Item Number) is used to uniquely identify trade items globally. There are different types of GTINs based on their lengths: GTIN-8, GTIN-12 (UPC), GTIN-13 (EAN), and GTIN-14. They all use a checksum formula to ensure the code's validity, which is based on the Modulo 10 (mod 10) algorithm. Here are the validation formulas for each type:


General Steps for GTIN Validation (Mod 10 Algorithm)

1. Start from the rightmost digit (ignoring the check digit).

2. Multiply each digit by a weight (alternating between 3 and 1).

   - For GTIN-12 and GTIN-13, start with 1.

   - For GTIN-8 and GTIN-14, start with 3.

3. Sum all the products.

4. Take the sum modulo 10.

5. Subtract the result from 10 to get the check digit.

6. If the result is 10, the check digit is 0.


 GTIN-8 Validation Formula

For a GTIN-8 (which has 7 digits + 1 check digit):

1. Multiply each digit by alternating weights of 3 and 1, starting with 3.

2. Sum the results.

3. Take the sum modulo 10 and subtract from 10 to get the check digit.


Example: GTIN-8 = `1234567` (7 digits, check digit will be calculated)

- (1 * 3) + (2 * 1) + (3 * 3) + (4 * 1) + (5 * 3) + (6 * 1) + (7 * 3) = 3 + 2 + 9 + 4 + 15 + 6 + 21 = 60

- 60 % 10 = 0

- Check digit is 0, so the valid GTIN-8 is `12345670`.


 GTIN-12 (UPC-A) Validation Formula

For a GTIN-12 (which has 11 digits + 1 check digit):

1. Multiply each digit by alternating weights of 1 and 3, starting with 1.

2. Sum the results.

3. Take the sum modulo 10 and subtract from 10 to get the check digit.


Example: GTIN-12 = `03600029145` (11 digits, check digit will be calculated)

- (0 * 1) + (3 * 3) + (6 * 1) + (0 * 3) + (0 * 1) + (2 * 3) + (9 * 1) + (1 * 3) + (4 * 1) + (5 * 3) = 0 + 9 + 6 + 0 + 0 + 6 + 9 + 3 + 4 + 15 = 52

- 52 % 10 = 2

- Check digit is 10 - 2 = 8, so the valid GTIN-12 is `036000291458`.


 GTIN-13 (EAN) Validation Formula

For a GTIN-13 (which has 12 digits + 1 check digit):

1. Multiply each digit by alternating weights of 1 and 3, starting with 1.

2. Sum the results.

3. Take the sum modulo 10 and subtract from 10 to get the check digit.


Example: GTIN-13 = `400638133393` (12 digits, check digit will be calculated)

- (4 * 1) + (0 * 3) + (0 * 1) + (6 * 3) + (3 * 1) + (8 * 3) + (1 * 1) + (3 * 3) + (3 * 1) + (3 * 3) + (9 * 1) + (3 * 3) = 4 + 0 + 0 + 18 + 3 + 24 + 1 + 9 + 3 + 9 + 9 + 9 = 89

- 89 % 10 = 9

- Check digit is 10 - 9 = 1, so the valid GTIN-13 is `4006381333931`.


 GTIN-14 Validation Formula

For a GTIN-14 (which has 13 digits + 1 check digit):

1. Multiply each digit by alternating weights of 3 and 1, starting with 3.

2. Sum the results.

3. Take the sum modulo 10 and subtract from 10 to get the check digit.


Example: GTIN-14 = `1234567890123` (13 digits, check digit will be calculated)

- (1 * 3) + (2 * 1) + (3 * 3) + (4 * 1) + (5 * 3) + (6 * 1) + (7 * 3) + (8 * 1) + (9 * 3) + (0 * 1) + (1 * 3) + (2 * 1) + (3 * 3) = 3 + 2 + 9 + 4 + 15 + 6 + 21 + 8 + 27 + 0 + 3 + 2 + 9 = 109

- 109 % 10 = 9

- Check digit is 10 - 9 = 1, so the valid GTIN-14 is `12345678901231`.