i try to make a code that if the user not inputing the photo they will get the message "you're not yet inputing the photo" i was using this code to do that
const isEmpty = (value) =>
value === undefined ||
value === null ||
(typeof value === "object" && Object.keys(value).length === 0) ||
(typeof value === "string" && value.trim().length === 0);
module.exports = isEmpty;
and calling them by :
const Validator = require("validator");
const isEmpty = require("./is-empty");
module.exports = validateCreatePost = (data) => {
let errors = {};
data.title = !isEmpty(data.title) ? data.title : "";
data.fieldContent = !isEmpty(data.fieldContent) ? data.fieldContent : "";
data.imageContent = !isEmpty(data.imageContent) ? data.imageContent : "";
data.genreContent = !isEmpty(data.genreContent) ? data.genreContent : "";
if (!Validator.isLength(data.title, { min: 5, max: 256 })) {
errors.title = "Title must be between 5 and 256 characters";
}
if (Validator.isEmpty(data.title)) {
errors.title = "Title field is required";
}
if (!Validator.isLength(data.fieldContent, { min: 100 })) {
errors.fieldContent = "Body field need atleast 100 characters";
}
if (Validator.isEmpty(data.fieldContent)) {
errors.fieldContent = "Body field is required";
}
if (Validator.isEmpty(data.imageContent)) {
errors.imageContent = "Image field is required";
}
if (Validator.isEmpty(data.genreContent)) {
errors.genreContent = "Genre is required";
}
return {
errors,
isValid: isEmpty(errors),
};
};
but whenever i try to input the photo from Postman they always give me this message
i'm stuck to solve this problem.