您可以使用正则表达式。
我过去曾经使用过。
UserSchema.path('email').validate(function (email) { var emailRegex = /^([w-.]+@([w-]+.)+[w-]{2,4})?$/; return emailRegex.test(email.text); // Assuming email has a text attribute}, 'The e-mail field cannot be empty.')
您可以使用正则表达式。
我过去曾经使用过。
UserSchema.path('email').validate(function (email) { var emailRegex = /^([w-.]+@([w-]+.)+[w-]{2,4})?$/; return emailRegex.test(email.text); // Assuming email has a text attribute}, 'The e-mail field cannot be empty.')