@@ -212,7 +212,6 @@ Field.prototype.customFilter = function (func) {
212
212
213
213
var MESSAGES = {
214
214
isDate : "%s is not a date" ,
215
- isEmail : "%s is not an email address" ,
216
215
isUrl : "%s is not a URL" ,
217
216
isIP : "%s is not an IP address" ,
218
217
isAlpha : "%s contains non-letter characters" ,
@@ -225,7 +224,7 @@ var MESSAGES = {
225
224
} ;
226
225
227
226
Object . keys ( ValidatorPrototype ) . forEach ( function ( name ) {
228
- if ( name . match ( / ^ ( c o n t a i n s | n o t C o n t a i n s | e q u a l s | c h e c k | v a l i d a t e | a s s e r t | e r r o r | l e n | i s N u m e r i c | i s D e c i m a l | i s F l o a t | r e g e x | n o t R e g e x | i s | n o t | n o t N u l l | i s N u l l ) $ / ) ) {
227
+ if ( name . match ( / ^ ( c o n t a i n s | n o t C o n t a i n s | e q u a l s | c h e c k | v a l i d a t e | a s s e r t | e r r o r | l e n | i s N u m e r i c | i s D e c i m a l | i s E m a i l | i s F l o a t | r e g e x | n o t R e g e x | i s | n o t | n o t N u l l | i s N u l l ) $ / ) ) {
229
228
return ;
230
229
}
231
230
@@ -308,6 +307,16 @@ Field.prototype.isFloat = Field.prototype.isDecimal = function (message) {
308
307
} ) ;
309
308
} ;
310
309
310
+ // super simple email validation
311
+ Field . prototype . isEmail = function ( message ) {
312
+ return this . add ( function ( value ) {
313
+ if ( typeof value != 'string' || ! ( / \S + @ \S + / ) . test ( value ) ) {
314
+ return { error : message || "%s is not an email address" } ;
315
+ }
316
+ return { valid : true } ;
317
+ } ) ;
318
+ } ;
319
+
311
320
Field . prototype . isString = function ( message ) {
312
321
return this . add ( function ( value ) {
313
322
if ( ! object . isString ( value ) ) {
0 commit comments