Sha256: a30fea7e62f663f88c618e57dcc482691158f88e59b97ae4b0af15f84a5b1ce6

Contents?: true

Size: 1.08 KB

Versions: 7

Compression:

Stored size: 1.08 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 some content in field, but does not check the specific content.
  
  @class
  @extends SC.Validator
  @author Charles Jolley
  @version 1.0
*/
SC.Validator.NotEmpty = SC.Validator.extend(
/** @scope SC.Validator.NotEmpty.prototype */ {
  
  validate: function(form, field) {
    var value = field.get('fieldValue'); 
    if (SC.none(value))
      return NO;

    if (! SC.none(value.length))
      return value.length > 0;

    return YES;
  },
  
  validateError: function(form, field) {
    var label = field.get('errorLabel') || 'Field' ;
    return SC.$error("Invalid.NotEmpty(%@)".loc(label.capitalize()), field.get('errorLabel'));
  }
    
}) ;

Version data entries

7 entries across 7 versions & 2 rubygems

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