Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
"user validation failed: passsword: Path `passsword` is required."

Here is my Mongoose model:

    const mongoose=require('mongoose')

const userSchema=new mongoose.Schema({
    firstName:{
        type:String,
        required:true
    },
    middleName:{
        type:String,
    },
  
    lastName:{
        type:String,
        required:true,
    },
    passsword:{
        type: String,
        required: true,
    },
    email:{
        type:String,
        unique:true,
        sparse:true
    },
    phoneNumber:{
        type:Number
    },
    address:{
        permanentAddress:String,
        temporaryAddress:[String]
    },
    gender:{
        type:String,
        enum:['male','female','others']
    },
    dob:{
        type:Date
    },
    country:{
        type:String,
        default:'Nepal'
    },
    image:{
        type:[String]
    },
    role:{
        type:Number,
        default:2
    },
    isArchived:{
        type:Boolean,
        default:false
    },
    status:{
        type:String,
        enum:['active','inactive','frequent'],
        default:'active'
    },
    passwordResetTOken:String,
    passwordResetTokenExpiry:String
})


const userModel=mongoose.model('user',userSchema)
module.exports=userModel

The controller is:

    function insert(data){
    return new Promise(function(resolve,reject){
        const newUser=new userModel
        newUser.password = passwordHash.generate(data.password)
        newUser.firstName=data.firstName
        newUser.lastName=data.lastName
        newUser.dob=data.dob
        console.log("new user is",newUser.password)
        console.log("mapped user is",newUser)
        newUser.save(function(err,done){
             if(err){
                 return reject(err)
             }
             console.log("user is",done)
             resolve(done)
         }) 
    })

}

I am getting error:


                    "name": "ValidatorError",
                "message": "Path `passsword` is required.",

But req.body has:

     {
  firstName: 'rajiv',
  lastName: 'dahal',
  password: 'admin',
  dob: '2021/03/03'
}

What is my mistake?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You have a typo when defining User Schema. You have 3 s instead of 2 for the name of password property. Just update you User Schema:

passsword -> password

about 4 years ago · Juan Pablo Isaza Report

0

should be password not passsword

passsword:{
  type: String,
  required: true,
},
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!