title: Validation Error in mongoose and node.js (ERROR IS BELOW)
body: <p>I am getting this error</p>
  <p>this.$__.validationError = new ValidationError(this);</p>
  <p>The full error message will be below the codes</p>
  <p>index.js file</p>
  <pre><code>//Requiring Dependencies
  const express = require('express');
  const app = express();
  
  const mongoose = require('mongoose');
  
  const path = require('path');
  
  const session = require('express-session');
  
  const passport = require('passport');
  const LocalStrategy = require('passport-local')
  
  //Require Models
  const Product = require('./models/product');
  const User = require('./models/user');
  
  //To run and parse EJS
  const engine = require('ejs-mate');
  
  //Connecting to DB server
  mongoose.connect('mongodb://localhost:27017/ecom', {
      useNewUrlParser: true,
      useUnifiedTopology: true,
  })
      .then(() =&gt; {
          console.log('DATABASE CONNECTED')
      })
      .catch(err =&gt; {
          console.log('SOMETHING WENT WRONG WITH MONGO')
          console.log(err)
      })
  
      //Using EJS-Mate
      app.engine('ejs' , engine);
      app.set('view engine' , 'ejs');
      app.set('views' , path.join(__dirname, 'views'));
  
      const sessionConfig = {
          secret: 'secrethere',
          resave: false,
          saveUninitialized: true,
          cookie: {
              httpOnly: true,
              expires: Date.now() + 1000 * 60 * 60 * 24 * 7,
              maxAge: 1000 * 60 * 60 * 24 * 7
          }
      }
      app.use(session(sessionConfig))
  
      //Using Passport
      app.use(passport.initialize())
      //So user does not have to login after every single request
      app.use(passport.session())
      passport.use(new LocalStrategy(User.authenticate()))
  
      
      //How to store a user in the session
      passport.serializeUser(User.serializeUser());
  
      //How to get user out of that session
      passport.deserializeUser(User.deserializeUser());
  
  
      app.use(express.urlencoded({extended: true}));
  
      //For use of files like js and css in public directory
      app.use(express.static(path.join(__dirname, './public')))
  
      app.use(express.static(path.join(__dirname, './images')))
  
     
  
  
      app.get('/' , (req , res) =&gt; {
  
      })
  
      app.get('/home' , (req , res) =&gt; {
          res.render('pages/homepage')
      })
  
      app.get('/login' , (req , res) =&gt; {
          res.render('pages/loginPage')
      })
  
      app.get('/signup' ,(req , res) =&gt; {
          res.render('pages/signup')
      })
  
      //Creating a new user
      app.post('/signup' , async(req , res) =&gt; {
          const {username , email, password, country, city, zipcode, street} = req.body
          const user =  new User({
              username,
              email,
              country,
              city,
              zipcode,
              street
          })
        const registeredUser = await User.register(user, password);
        console.log(registeredUser)
      })
  
  
      //Port
  app.listen(3000, () =&gt; {
      console.log('LISTENING ON PORT 3000')
  })
  </code></pre>
  <p>This is the user model file</p>
  <pre><code>const express = require('express')
  const mongoose = require('mongoose');
  let Schema = mongoose.Schema;
  const passportLocalMongoose = require('passport-local-mongoose');
  
  const userSchema = new Schema({
      email: {
          type: String,
          required: true,
          unique: true
      },
      username: {
          type: String,
          required: true
      },
      address: {
          country: {
              type: String,
              required: true
          },
          city:{
              type: String,
              required: true
          },
          street: {
              type: String,
              required: true
          },
          zipcode: {
              type: String,
              required: true
          }
      },
      shipping_address: {
          country: {
              type: String,
              required: true
          },
          street: {
              type: String,
              required: true
          },
          zipcode: {
              type: String,
              required: true
          }
      }
  });
  //Using Paspport Plugin
  userSchema.plugin(passportLocalMongoose);
  
  module.exports = mongoose.model('User' , userSchema);
  </code></pre>
  <p>This is the full error</p>
  <blockquote>
  <p>C:\Users\hadiz\Desktop\Business\portfolioprojects\ecommerce\node_modules\mongoose\lib\document.js:2907
  this.$__.validationError = new ValidationError(this);
  ^</p>
  <p>ValidationError: User validation failed: shipping_address.zipcode:
  Path <code>shipping_address.zipcode</code> is required., shipping_address.street:
  Path <code>shipping_address.street</code> is required., shipping_address.country:
  Path <code>shipping_address.country</code> is required., address.zipcode: Path
  <code>address.zipcode</code> is required., address.street: Path <code>address.street</code>
  is required., address.city: Path <code>address.city</code> is required.,
  address.country: Path <code>address.country</code> is required.
  at model.Document.invalidate</p>
  </blockquote>