Mongoose-验证电子邮件语法

3qpi33ja  于 2022-09-18  发布在  Go
关注(0)|答案(0)|浏览(64)

我有一个针对用户的Mongoose模式(UserSchema),我想验证电子邮件是否具有正确的语法。我目前使用的验证如下:

UserSchema.path('email').validate(function (email) {
  return email.length
}, 'The e-mail field cannot be empty.')

但是,这只检查该字段是否为空,而不检查语法。

是否已经存在可以重复使用的内容,或者我是否必须想出自己的方法并在验证函数中调用该方法?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题