{"size": 565, "ext": "js", "max_stars_repo_path": "app/models/user.js", "max_stars_repo_name": "sjain/qman", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/models/user.js", "max_issues_repo_name": "sjain/qman", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app/models/user.js", "max_forks_repo_name": "sjain/qman", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.7307692308, "max_line_length": 57, "alphanum_fraction": 0.6194690265}
var mongoose = require('mongoose');
var Schema = mongoose.Schema;

var UserSchema = new Schema({
  first_name: {
    type: String,
    required: "First Name is required"
  },
  last_name: {
    type: String,
    required: "Last Name is required"
  },
  email: {
    type: String,
    required: false
  },
});

UserSchema.path('email').validate(function (email) {
  console.log('email:', email);
  var emailRegex = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
  return emailRegex.test(email);
}, 'Please enter a valid email address.')

mongoose.model('User', UserSchema);
