Skip to content

Commit

Permalink
🐛 [feat/config] #77 enable configuration upload validation
Browse files Browse the repository at this point in the history
Signed-off-by: JAGFx <contact@jagfx.fr>
  • Loading branch information
JAGFx committed Dec 30, 2021
1 parent 774da12 commit 61f7915
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/utils/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export const upload = (file, target) => {
reader.onload = (evt) => {
try {
const data = JSON.parse(evt.target.result);
const checkResult = uploadChecker(data);
const checkResult = uploadChecker(data, target);

if (!checkResult.state)
throw 'An entry required was not found: ' + checkResult.value;
Expand Down Expand Up @@ -198,20 +198,20 @@ export const getFieldValues = (fieldId) => {
else return new Promise((resolve) => resolve([]));
};

const uploadChecker = (input) => {
const uploadChecker = (input, target) => {
let result = {
state: true
};

//Object.entries(emptyData()).forEach((entry) => {
// const key = entry[0];
//
// if (!Object.hasOwnProperty.call(input, key))
// result = {
// state: false,
// value: key
// };
//});
Object.entries(emptyData()[target]).forEach((entry) => {
const key = entry[0];

if (!Object.hasOwnProperty.call(input, key))
result = {
state: false,
value: key
};
});

return result;
};

0 comments on commit 61f7915

Please sign in to comment.