barcodes/validation/rules.go

100 lines
1.3 KiB
Go
Raw Normal View History

2023-09-01 19:08:59 +01:00
package validation
import "regexp"
// This needs to be a map of structs
type rule struct {
minLength uint64
maxLength uint64
charset regexp.Regexp
divisible uint8
}
2023-09-01 22:47:46 +01:00
var FormatRules = map[string]rule{
2023-09-01 19:08:59 +01:00
2023-09-01 20:50:47 +01:00
"2of5": {
2023-09-01 22:14:11 +01:00
minLength: 2,
maxLength: 80,
charset: *NUMERAL,
divisible: 1,
},
"2of5interleaved": {
2023-09-01 20:50:47 +01:00
minLength: 2,
maxLength: 80,
charset: *NUMERAL,
divisible: 2,
},
2023-09-01 19:08:59 +01:00
2023-09-01 20:50:47 +01:00
"aztec": {
minLength: 1,
maxLength: 3067,
charset: *ANY,
divisible: 1,
},
2023-09-01 19:08:59 +01:00
2023-09-01 20:50:47 +01:00
"codabar": {
minLength: 1,
maxLength: 100,
charset: *CODABAR,
divisible: 1,
},
2023-09-01 19:08:59 +01:00
2023-09-01 23:01:08 +01:00
/* "code39": {
minLength: 1,
maxLength: 80,
charset: *CODE39,
divisible: 1,
},
*/
2023-09-01 20:50:47 +01:00
"code93": {
minLength: 1,
maxLength: 80,
charset: *ASCII,
divisible: 1,
},
2023-09-01 19:08:59 +01:00
2023-09-01 20:50:47 +01:00
"code128": {
minLength: 1,
maxLength: 80,
charset: *ASCII,
divisible: 1,
},
2023-09-01 19:08:59 +01:00
2023-09-01 20:50:47 +01:00
"datamatrix": {
minLength: 1,
maxLength: 2335,
charset: *ANY,
divisible: 1,
},
2023-09-01 23:01:08 +01:00
/*
"ean8": {
minLength: 7,
maxLength: 7,
charset: *NUMERAL,
divisible: 1,
},
"ean13": {
minLength: 12,
maxLength: 12,
charset: *NUMERAL,
divisible: 1,
},
*/
2023-09-01 20:50:47 +01:00
"pdf417": {
minLength: 1,
maxLength: 1100,
charset: *ANY,
divisible: 1,
},
2023-09-01 19:08:59 +01:00
2023-09-01 20:50:47 +01:00
"qr": {
minLength: 1,
maxLength: 4296,
charset: *ISO88591,
divisible: 1,
},
2023-09-01 19:08:59 +01:00
}