Skip to content

Instantly share code, notes, and snippets.

@Anderson-Juhasc
Created May 23, 2018 21:18
Show Gist options
  • Save Anderson-Juhasc/4984e099a9f0bf38f0df4792d888df60 to your computer and use it in GitHub Desktop.
Save Anderson-Juhasc/4984e099a9f0bf38f0df4792d888df60 to your computer and use it in GitHub Desktop.
const isImage = (name, msg, req) => {
let proof = typeof req.files[name] !== "undefined" ? req.files[name] : undefined;
if (!proof) {
throw new Error(msg)
}
switch (proof.type) {
case 'image/jpeg':
return 'image/jpeg';
case 'image/png':
return 'image/png';
default:
throw new Error('Documento de identificação precisa ser um arquivo .jpeg ou .png.');
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment