mirror of
https://github.com/sstent/expressmongotest.git
synced 2026-01-25 16:42:00 +00:00
almost rebased
This commit is contained in:
18
chapter25/10_user_schema_with_validated_email.js
Normal file
18
chapter25/10_user_schema_with_validated_email.js
Normal file
@@ -0,0 +1,18 @@
|
||||
var mongoose = require('mongoose');
|
||||
|
||||
// simple but incomplete email regexp:
|
||||
var emailRegexp = /.+\@.+\..+/;
|
||||
|
||||
var UserSchema = new mongoose.Schema({
|
||||
username: {type: String, unique: true},
|
||||
name: String,
|
||||
password: String,
|
||||
email: {
|
||||
type: String,
|
||||
required: true,
|
||||
match: emailRegexp
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = UserSchema;
|
||||
Reference in New Issue
Block a user