Spaces:
Runtime error
Runtime error
File size: 512 Bytes
8c7b7ca | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | const VENDOR_CODE_REGEX = /^([A-Z]{4})-DSS-(\d{2})-(\d{3})$/;
function normalizeVendorCode(value) {
return String(value || '').trim().toUpperCase();
}
function parseVendorCode(value) {
const normalized = normalizeVendorCode(value);
const match = normalized.match(VENDOR_CODE_REGEX);
if (!match) {
return null;
}
return {
normalized,
name4: match[1],
year: match[2],
sequence: match[3]
};
}
module.exports = {
VENDOR_CODE_REGEX,
normalizeVendorCode,
parseVendorCode
};
|