Skip to content
Snippets Groups Projects
Commit 8232deb8 authored by V S Tharunika's avatar V S Tharunika
Browse files

schema is a part of joi

parent 276b54a4
Branches
No related tags found
No related merge requests found
......@@ -2,16 +2,16 @@ const Joi = require('joi')
module.exports={
register(reg, res, next){
register(req, res, next){
const schema ={
const schema =Joi.object({
email: Joi.string().email(),
password: Joi.string().regex(
new regExp('^[a-zA-Z0-9]{8-32}$')
new RegExp('^[a-zA-Z0-9]{8-32}$')
)
}
})
const {error, value} = Joi.Validate(req.body, schema)
const {error, value} = schema.validate(req.body)
if(error){
switch(error.details[0].context.key){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment