email in mongoose code example
Example: email validation in mongoose
import { isEmail } from 'validator';
// ...
const EmailSchema = new Schema({
email: {
//... other setup
validate: [ isEmail, 'invalid email' ]
}
});
import { isEmail } from 'validator';
// ...
const EmailSchema = new Schema({
email: {
//... other setup
validate: [ isEmail, 'invalid email' ]
}
});