Skip to content

Instantly share code, notes, and snippets.

@amandeepmittal
Created December 30, 2018 06:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amandeepmittal/f03e70c0ec4eeb1c4467167d3a75f887 to your computer and use it in GitHub Desktop.
Save amandeepmittal/f03e70c0ec4eeb1c4467167d3a75f887 to your computer and use it in GitHub Desktop.
const Joi = require('joi');
const schema = Joi.object()
.keys({
username: Joi.string()
.alphanum()
.min(3)
.max(30)
.required(),
password: Joi.string().regex(/^[a-zA-Z0-9]{3,30}$/),
access_token: [Joi.string(), Joi.number()],
birthyear: Joi.number()
.integer()
.min(1900)
.max(2013),
email: Joi.string().email({ minDomainAtoms: 2 })
})
.with('username', 'birthyear')
.without('password', 'access_token');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment