@montevideo-tech/cmcd-validator
Version:
This is a library created to validate CMCD
23 lines (17 loc) • 582 B
JavaScript
import jsLogger from 'js-logger';
import { warningDescription, warningTypes } from './constants.js';
import getKeyByValue from './getKeyByValue.js';
export const createWarning = (type, requestID, key, value) => {
jsLogger.useDefaults({ defaultLevel: jsLogger.TRACE });
if (!Object.values(warningTypes).includes(type)) {
return -1;
}
const warning = getKeyByValue(warningTypes, type);
jsLogger.info(`${requestID}: Warning in '${key}': ${warningDescription[warning]}`);
return {
type,
key,
value,
description: warningDescription[warning],
};
};