Created
February 19, 2019 08:00
-
-
Save tarusharora/10df9282b5a56ec1d9e3ae7cfbe2f22d to your computer and use it in GitHub Desktop.
Auth Validations for sign-up and sign-in
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
const nconf = require('nconf'); | |
const userPasswordRegex = nconf.get('userPasswordRegex'); | |
const validatePostLogin = { | |
schema: { | |
body: { | |
type: 'object', | |
properties: { | |
email: { type: 'string', format: 'email' }, | |
password: { type: 'string', format: 'regex', pattern: userPasswordRegex }, | |
}, | |
required: ['email', 'password'], | |
}, | |
}, | |
}; | |
const validatePostSignup = { | |
schema: { | |
body: { | |
type: 'object', | |
properties: { | |
email: { type: 'string', format: 'email' }, | |
password: { | |
type: 'string', format: 'regex', pattern: userPasswordRegex, minLength: 6, maxLength: 20, | |
}, | |
}, | |
required: ['email', 'password'], | |
}, | |
}, | |
}; | |
module.exports = { | |
validatePostLogin, | |
validatePostSignup, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment