- ERROR를 해결한
키에러와 키의값이 비어져있는지를 확인해주는 함수를 모듈화여 운영🔑
- checkvalidation.js 모듈
<script>
export const checkEmptyKeyOfValue = (userInfo) => {
const userInputData = Object.entries(userInfo);
const userInputInfo = new Map(userInputData);
for (let data of userInputInfo) {
if (data[1] === '') return data[0];
}
};
export const checkEmptyKey = (KeyList, userInfo) => {
const keyArr = [];
let emptyKeyArr = [];
const userInputData = Object.entries(userInfo);
const userInputInfo = new Map(userInputData);
for (let key of userInputInfo.keys()) {
if (KeyList.includes(key)) {
keyArr.push(key);
const InputKeyAndListArr = keyArr.concat(KeyList);
const emptyKey = InputKeyAndListArr.filter((e) => !keyArr.includes(e));
emptyKeyArr = [...emptyKey];
}
}
return emptyKeyArr;
};
</script>
- signInController.js에서 에러 캐치
<script>
if (emptyKey.length !== 0) {
next(new AppError.keyError(`${emptyKey} 키가 비어있습니다`));
return;
}
const emptyKeyOfValue = checkEmptyKeyOfValue(userInfo);
if (emptyKeyOfValue) {
next(
new AppError.valueOfKeyError(`키의 ${emptyKeyOfValue} 값이 비어있습니다`)
);
return;
}
</script>
그런 점~ 대단한 점~