Skip to content

Instantly share code, notes, and snippets.

@tarusharora
Created February 19, 2019 08:00
Show Gist options
  • Save tarusharora/10df9282b5a56ec1d9e3ae7cfbe2f22d to your computer and use it in GitHub Desktop.
Save tarusharora/10df9282b5a56ec1d9e3ae7cfbe2f22d to your computer and use it in GitHub Desktop.
Auth Validations for sign-up and sign-in
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