Allow for clear and correct for Select allowClear sending undefined and convert that to null. Overload UndefinedtoNull to have an array of keys
11 lines
276 B
JavaScript
11 lines
276 B
JavaScript
export default function UndefinedToNull(obj, keys) {
|
|
Object.keys(obj).forEach((key) => {
|
|
if (keys && keys.indexOf(key) >= 0) {
|
|
if (obj[key] === undefined) obj[key] = null;
|
|
} else {
|
|
if (obj[key] === undefined) obj[key] = null;
|
|
}
|
|
});
|
|
return obj;
|
|
}
|