Closed michaeljota closed 8 years ago
You should specify a regex in match
. So you're example would be:
class User extends Document {
constructor(){
super();
//Just the part where using the match.
this.email = {
type: String,
match: /.+\@.+\..+/
}
}
Although it probably wouldn't hurt to allow plain regex strings as well (like you're using).
Just remove the single quotes ('
). Here is a quick RegExp example:
var emailRegex = /.+\@.+\..+/;
emailRegex.test('john@example.com'); // true
emailRegex.test('example.com'); // false
Unless you have any other follow-up questions, I'm going to close the issue. Thanks!
Thanks. :+1:
I trying to use 'match', but as #41 it throws not a function.
Here is my schema: