@pdfme/common
Advanced tools
Comparing version 1.2.3 to 1.2.4
@@ -410,3 +410,17 @@ "use strict"; | ||
}); | ||
test('gs1datamatrix', () => { | ||
// https://www.gs1.org/docs/barcodes/GS1_DataMatrix_Guideline.pdf | ||
// find the GTIN application identifier, regex for "(01)" and the digits after it until | ||
// another "(" or end of string | ||
const type = 'gs1datamatrix'; | ||
let valid = "(01)12244668801011(17)250712(10)22322SSD3"; | ||
let valid_12 = "(01)1224466880108(17)250712(10)22322SSD3"; | ||
let invalid_bad_checkdigit = "(01)12244668801014(17)250712(10)22322SSD3"; | ||
const blank = ''; | ||
expect((0, helper_1.validateBarcodeInput)(type, valid)).toEqual(true); | ||
expect((0, helper_1.validateBarcodeInput)(type, valid_12)).toEqual(true); | ||
expect((0, helper_1.validateBarcodeInput)(type, invalid_bad_checkdigit)).toEqual(false); | ||
expect((0, helper_1.validateBarcodeInput)(type, blank)).toEqual(false); | ||
}); | ||
}); | ||
//# sourceMappingURL=helper.test.js.map |
@@ -196,2 +196,15 @@ "use strict"; | ||
} | ||
if (type === 'gs1datamatrix') { | ||
let ret = false; | ||
// find the GTIN application identifier, regex for "(01)" and the digits after it until another "(" | ||
const regexp = /\((01)\)(\d*)(\(|$)/; | ||
let res = input.match(regexp); | ||
if (res != null && | ||
res[1] === '01' && | ||
(res[2].length === 14 || res[2].length === 8 || res[2].length === 12 || res[2].length === 13)) { | ||
let gtin = res[2]; | ||
ret = validateCheckDigit(gtin, gtin.length); | ||
} | ||
return ret; | ||
} | ||
return false; | ||
@@ -198,0 +211,0 @@ }; |
@@ -12,3 +12,3 @@ "use strict"; | ||
// prettier-ignore | ||
exports.barcodeSchemaTypes = ['qrcode', 'japanpost', 'ean13', 'ean8', 'code39', 'code128', 'nw7', 'itf14', 'upca', 'upce']; | ||
exports.barcodeSchemaTypes = ['qrcode', 'japanpost', 'ean13', 'ean8', 'code39', 'code128', 'nw7', 'itf14', 'upca', 'upce', 'gs1datamatrix']; | ||
const notBarcodeSchemaTypes = ['text', 'image']; | ||
@@ -15,0 +15,0 @@ exports.schemaTypes = [...notBarcodeSchemaTypes, ...exports.barcodeSchemaTypes]; |
@@ -385,3 +385,17 @@ import { readFileSync } from 'fs'; | ||
}); | ||
test('gs1datamatrix', () => { | ||
// https://www.gs1.org/docs/barcodes/GS1_DataMatrix_Guideline.pdf | ||
// find the GTIN application identifier, regex for "(01)" and the digits after it until | ||
// another "(" or end of string | ||
const type = 'gs1datamatrix'; | ||
let valid = "(01)12244668801011(17)250712(10)22322SSD3"; | ||
let valid_12 = "(01)1224466880108(17)250712(10)22322SSD3"; | ||
let invalid_bad_checkdigit = "(01)12244668801014(17)250712(10)22322SSD3"; | ||
const blank = ''; | ||
expect(validateBarcodeInput(type, valid)).toEqual(true); | ||
expect(validateBarcodeInput(type, valid_12)).toEqual(true); | ||
expect(validateBarcodeInput(type, invalid_bad_checkdigit)).toEqual(false); | ||
expect(validateBarcodeInput(type, blank)).toEqual(false); | ||
}); | ||
}); | ||
//# sourceMappingURL=helper.test.js.map |
@@ -181,4 +181,17 @@ import { z } from 'zod'; | ||
} | ||
if (type === 'gs1datamatrix') { | ||
let ret = false; | ||
// find the GTIN application identifier, regex for "(01)" and the digits after it until another "(" | ||
const regexp = /\((01)\)(\d*)(\(|$)/; | ||
let res = input.match(regexp); | ||
if (res != null && | ||
res[1] === '01' && | ||
(res[2].length === 14 || res[2].length === 8 || res[2].length === 12 || res[2].length === 13)) { | ||
let gtin = res[2]; | ||
ret = validateCheckDigit(gtin, gtin.length); | ||
} | ||
return ret; | ||
} | ||
return false; | ||
}; | ||
//# sourceMappingURL=helper.js.map |
@@ -9,3 +9,3 @@ /* eslint dot-notation: "off"*/ | ||
// prettier-ignore | ||
export const barcodeSchemaTypes = ['qrcode', 'japanpost', 'ean13', 'ean8', 'code39', 'code128', 'nw7', 'itf14', 'upca', 'upce']; | ||
export const barcodeSchemaTypes = ['qrcode', 'japanpost', 'ean13', 'ean8', 'code39', 'code128', 'nw7', 'itf14', 'upca', 'upce', 'gs1datamatrix']; | ||
const notBarcodeSchemaTypes = ['text', 'image']; | ||
@@ -12,0 +12,0 @@ export const schemaTypes = [...notBarcodeSchemaTypes, ...barcodeSchemaTypes]; |
import { z } from 'zod'; | ||
import { Lang, Size, Alignment, BarcodeSchemaType, SchemaType, CommonSchema as _CommonSchema, TextSchema, ImageSchema, BarcodeSchema, Schema, SchemaInputs, SchemaForUI, Font, BasePdf, Template, CommonProps, GeneratorOptions, GenerateProps, UIOptions, UIProps, PreviewProps, PreviewReactProps, DesignerProps, DesignerReactProps } from './schema.js'; | ||
declare type CommonSchema = z.infer<typeof _CommonSchema>; | ||
export declare const schemaTypes: readonly ["text", "image", "qrcode", "japanpost", "ean13", "ean8", "code39", "code128", "nw7", "itf14", "upca", "upce"]; | ||
export declare const schemaTypes: readonly ["text", "image", "qrcode", "japanpost", "ean13", "ean8", "code39", "code128", "nw7", "itf14", "upca", "upce", "gs1datamatrix"]; | ||
export declare const isTextSchema: (arg: CommonSchema) => arg is { | ||
@@ -37,3 +37,3 @@ type: "text"; | ||
export declare const isBarcodeSchema: (arg: CommonSchema) => arg is { | ||
type: "qrcode" | "japanpost" | "ean13" | "ean8" | "code39" | "code128" | "nw7" | "itf14" | "upca" | "upce"; | ||
type: "qrcode" | "japanpost" | "ean13" | "ean8" | "code39" | "code128" | "nw7" | "itf14" | "upca" | "upce" | "gs1datamatrix"; | ||
height: number; | ||
@@ -40,0 +40,0 @@ width: number; |
{ | ||
"name": "@pdfme/common", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"sideEffects": false, | ||
@@ -5,0 +5,0 @@ "author": "hand-dot", |
@@ -231,4 +231,20 @@ import { z } from 'zod'; | ||
} | ||
if (type === 'gs1datamatrix') { | ||
let ret = false; | ||
// find the GTIN application identifier, regex for "(01)" and the digits after it until another "(" | ||
const regexp = /\((01)\)(\d*)(\(|$)/; | ||
let res = input.match(regexp); | ||
if ( | ||
res != null && | ||
res[1] === '01' && | ||
(res[2].length === 14 || res[2].length === 8 || res[2].length === 12 || res[2].length === 13) | ||
) { | ||
let gtin = res[2]; | ||
ret = validateCheckDigit(gtin, gtin.length); | ||
} | ||
return ret; | ||
} | ||
return false; | ||
}; |
@@ -13,3 +13,3 @@ /* eslint dot-notation: "off"*/ | ||
// prettier-ignore | ||
export const barcodeSchemaTypes = ['qrcode', 'japanpost', 'ean13', 'ean8', 'code39', 'code128', 'nw7', 'itf14', 'upca', 'upce'] as const; | ||
export const barcodeSchemaTypes = ['qrcode', 'japanpost', 'ean13', 'ean8', 'code39', 'code128', 'nw7', 'itf14', 'upca', 'upce', 'gs1datamatrix'] as const; | ||
const notBarcodeSchemaTypes = ['text', 'image'] as const; | ||
@@ -16,0 +16,0 @@ export const schemaTypes = [...notBarcodeSchemaTypes, ...barcodeSchemaTypes] as const; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
1035350
9093