Skip to content

Instantly share code, notes, and snippets.

@TerryFunggg
Created February 15, 2021 15:58
Show Gist options
  • Save TerryFunggg/2097ef39979d0c9993656285f7fa2166 to your computer and use it in GitHub Desktop.
Save TerryFunggg/2097ef39979d0c9993656285f7fa2166 to your computer and use it in GitHub Desktop.
writing javascript in fun way 1
exports.validateRegister = async (ctx, next) => {
const data = ctx.req.body;
const e = (data) => !!data.email && isEmail(data.email);
const p = (data) => !!data.password;
const n = (data) => !!data.name;
const checks = [e, p, n];
const isPass = (check) => check(data);
if (checks.every(isPass)) {
await next();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment