barcodes/validation/rules.go

100 lines
1.3 KiB
Go

package validation
import "regexp"
// This needs to be a map of structs
type rule struct {
minLength uint64
maxLength uint64
charset regexp.Regexp
divisible uint8
}
var FormatRules = map[string]rule{
"2of5": {
minLength: 2,
maxLength: 80,
charset: *NUMERAL,
divisible: 1,
},
"2of5interleaved": {
minLength: 2,
maxLength: 80,
charset: *NUMERAL,
divisible: 2,
},
"aztec": {
minLength: 1,
maxLength: 3067,
charset: *ANY,
divisible: 1,
},
"codabar": {
minLength: 1,
maxLength: 100,
charset: *CODABAR,
divisible: 1,
},
"code39": {
minLength: 1,
maxLength: 80,
charset: *CODE39,
divisible: 1,
},
"code93": {
minLength: 1,
maxLength: 80,
charset: *ASCII,
divisible: 1,
},
"code128": {
minLength: 1,
maxLength: 80,
charset: *ASCII,
divisible: 1,
},
"datamatrix": {
minLength: 1,
maxLength: 2335,
charset: *ANY,
divisible: 1,
},
"ean8": {
minLength: 7,
maxLength: 7,
charset: *NUMERAL,
divisible: 1,
},
"ean13": {
minLength: 12,
maxLength: 12,
charset: *NUMERAL,
divisible: 1,
},
"pdf417": {
minLength: 1,
maxLength: 1100,
charset: *ANY,
divisible: 1,
},
"qr": {
minLength: 1,
maxLength: 4296,
charset: *ISO88591,
divisible: 1,
},
}