Updates
This commit is contained in:
@@ -7,12 +7,13 @@ exports.default = grabParsedValue;
|
||||
const sanitize_html_1 = __importDefault(require("sanitize-html"));
|
||||
const sanitizeHtmlOptions_1 = __importDefault(require("../html/sanitizeHtmlOptions"));
|
||||
const encrypt_1 = __importDefault(require("../../dsql/encrypt"));
|
||||
const numberfy_1 = __importDefault(require("../../../utils/numberfy"));
|
||||
/**
|
||||
* # Update DB Function
|
||||
* @description
|
||||
*/
|
||||
function grabParsedValue({ value, tableSchema, encryptionKey, encryptionSalt, dataKey, }) {
|
||||
var _a, _b, _c;
|
||||
var _a, _b, _c, _d;
|
||||
let newValue = value;
|
||||
const targetFieldSchema = tableSchema
|
||||
? (_a = tableSchema === null || tableSchema === void 0 ? void 0 : tableSchema.fields) === null || _a === void 0 ? void 0 : _a.find((field) => field.fieldName === dataKey)
|
||||
@@ -37,6 +38,10 @@ function grabParsedValue({ value, tableSchema, encryptionKey, encryptionSalt, da
|
||||
!(value === null || value === void 0 ? void 0 : value.match(/./))) {
|
||||
newValue = "";
|
||||
}
|
||||
if (((_c = targetFieldSchema === null || targetFieldSchema === void 0 ? void 0 : targetFieldSchema.dataType) === null || _c === void 0 ? void 0 : _c.match(/int$|decimal|float|double/i)) &&
|
||||
typeof value == "string") {
|
||||
newValue = (0, numberfy_1.default)(value);
|
||||
}
|
||||
if (targetFieldSchema === null || targetFieldSchema === void 0 ? void 0 : targetFieldSchema.encrypted) {
|
||||
newValue =
|
||||
(0, encrypt_1.default)({
|
||||
@@ -60,7 +65,7 @@ function grabParsedValue({ value, tableSchema, encryptionKey, encryptionSalt, da
|
||||
newValue = undefined;
|
||||
}
|
||||
if (typeof newValue === "boolean" ||
|
||||
((_c = targetFieldSchema === null || targetFieldSchema === void 0 ? void 0 : targetFieldSchema.dataType) === null || _c === void 0 ? void 0 : _c.match(/boolean/i))) {
|
||||
((_d = targetFieldSchema === null || targetFieldSchema === void 0 ? void 0 : targetFieldSchema.dataType) === null || _d === void 0 ? void 0 : _d.match(/boolean/i))) {
|
||||
newValue = newValue ? 1 : 0;
|
||||
}
|
||||
return newValue;
|
||||
|
||||
Reference in New Issue
Block a user