1 // ==========================================================================
  2 // Project:   SproutCore - JavaScript Application Framework
  3 // Copyright: ©2006-2011 Strobe Inc. and contributors.
  4 //            Portions ©2008-2011 Apple Inc. All rights reserved.
  5 // License:   Licensed under MIT license (see license.js)
  6 // ==========================================================================
  7 
  8 sc_require('validators/validator') ;
  9 
 10 /**
 11   Requires some content in field, but does not check the specific content.
 12   
 13   @class
 14   @extends SC.Validator
 15   @author Charles Jolley
 16   @version 1.0
 17 */
 18 SC.Validator.NotEmpty = SC.Validator.extend(
 19 /** @scope SC.Validator.NotEmpty.prototype */ {
 20   
 21   validate: function(form, field) {
 22     var value = field.get('fieldValue');
 23     if (SC.none(value)) { return NO; }
 24     if (! SC.none(value.length)) { return value.length > 0; }
 25     return YES;
 26   },
 27   
 28   validateError: function(form, field) {
 29     var label = field.get('errorLabel') || 'Field' ;
 30     return SC.$error(SC.String.loc("Invalid.NotEmpty(%@)", SC.String.capitalize(label)), field.get('errorLabel'));
 31   }
 32 
 33 }) ;
 34