Sha256: 258e7a1c909e626d411535f2f03751d2a725617ad474bd83df2cd1cdc978bf1d

Contents?: true

Size: 1.3 KB

Versions: 7

Compression:

Stored size: 1.3 KB

Contents

// ==========================================================================
// Project:   SproutCore - JavaScript Application Framework
// Copyright: ©2006-2011 Strobe Inc. and contributors.
//            Portions ©2008-2010 Apple Inc. All rights reserved.
// License:   Licensed under MIT license (see license.js)
// ==========================================================================

sc_require('validators/validator') ;

/**
  Requires a valid email format.
  
  @class
  @extends SC.Validator
  @version 1.0
*/
SC.Validator.Email = SC.Validator.extend(
/** @scope SC.Validator.Email.prototype */ {
  
  validate: function(form, field) { 
    return (field.get('fieldValue') || '').match(/.+@.+\...+/) ; 
  },
  
  validateError: function(form, field) {
    var label = field.get('errorLabel') || 'Field' ;
    return SC.$error("Invalid.Email(%@)".loc(label), label) ;
  }  
    
}) ;

/**
  This variant allows an empty field as well as an email address.
  
  @class
  @extends SC.Validator.Email
  @author Charles Jolley
  @version 1.0
*/
SC.Validator.EmailOrEmpty = SC.Validator.Email.extend(
/** @scope SC.Validator.EmailOrEmpty.prototype */ {
  validate: function(form, field) {
    var value = field.get('fieldValue') ; 
    return (value && value.length > 0) ? value.match(/.+@.+\...+/) : true ;
  }
}) ;

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
spade-0.0.1 sproutcore/frameworks/foundation/validators/email.js
sproutcore-1.5.0.pre.5 lib/frameworks/sproutcore/frameworks/foundation/validators/email.js
sproutcore-1.5.0.pre.4.1 lib/frameworks/sproutcore/frameworks/foundation/validators/email.js
sproutcore-1.5.0.pre.4 lib/frameworks/sproutcore/frameworks/foundation/validators/email.js
sproutcore-1.5.0.pre.3 lib/frameworks/sproutcore/frameworks/foundation/validators/email.js
sproutcore-1.4.5 lib/frameworks/sproutcore/frameworks/foundation/validators/email.js
sproutcore-1.4.5-java lib/frameworks/sproutcore/frameworks/foundation/validators/email.js