Created
February 15, 2021 15:58
-
-
Save TerryFunggg/2097ef39979d0c9993656285f7fa2166 to your computer and use it in GitHub Desktop.
writing javascript in fun way 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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