dss-server / src /utils /vendorCode.js
yeshwanth-kr's picture
Upload 43 files
8c7b7ca verified
raw
history blame contribute delete
512 Bytes
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
};