feat: request middleware to convert empty strings to null.

This commit is contained in:
Ahmed Bouhuolia
2020-11-09 21:12:50 +02:00
parent f151e6242e
commit 0718d26181
5 changed files with 26 additions and 3 deletions

View File

@@ -195,6 +195,16 @@ const entriesAmountDiff = (newEntries, oldEntries, amountAttribute, idAttribute)
.value();
};
const convertEmptyStringsToNull = (obj) => {
return _.mapValues(obj, (value, key) => {
return typeof value === 'string' ?
value.trim() === '' ?
null :
value :
value;
});
};
export {
hashPassword,
origin,
@@ -214,4 +224,5 @@ export {
getDefinedOptions,
entriesAmountDiff,
convertEmptyStringsToNull,
};