Sha256: 9920193f3e2468d69594c616a1d4bac4ff5deb73906ef0582d71ccfe861e0c10

Contents?: true

Size: 916 Bytes

Versions: 22

Compression:

Stored size: 916 Bytes

Contents

// ==========================================================================
// Not Empty Validator
// Author: Charles Jolley
//
// Force a field to be not empty.
//
// ==========================================================================

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'); 
    var ret = !!value ;
    if (ret && value.length) ret = value.length > 0 ;
    return ret ;
  },
  
  validateError: function(form, field) {
    var label = field.get('errorLabel') || 'Field' ;
    return $error("Invalid.NotEmpty(%@)".loc(label.capitalize()), field.get('errorLabel'));
  }
    
}) ;

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
sproutcore-0.9.12 frameworks/sproutcore/validators/not_empty.js
sproutcore-0.9.11 frameworks/sproutcore/validators/not_empty.js
sproutcore-0.9.10 frameworks/sproutcore/validators/not_empty.js
sproutcore-0.9.15 frameworks/sproutcore/validators/not_empty.js
sproutcore-0.9.13 frameworks/sproutcore/validators/not_empty.js
sproutcore-0.9.14 frameworks/sproutcore/validators/not_empty.js
sproutcore-0.9.18 frameworks/sproutcore/validators/not_empty.js
sproutcore-0.9.16 frameworks/sproutcore/validators/not_empty.js
sproutcore-0.9.17 frameworks/sproutcore/validators/not_empty.js
sproutcore-0.9.19 frameworks/sproutcore/validators/not_empty.js
sproutcore-0.9.2 frameworks/sproutcore/validators/not_empty.js
sproutcore-0.9.20 frameworks/sproutcore/validators/not_empty.js
sproutcore-0.9.21 frameworks/sproutcore/validators/not_empty.js
sproutcore-0.9.22 frameworks/sproutcore/validators/not_empty.js
sproutcore-0.9.23 frameworks/sproutcore/validators/not_empty.js
sproutcore-0.9.5 frameworks/sproutcore/validators/not_empty.js
sproutcore-0.9.3 frameworks/sproutcore/validators/not_empty.js
sproutcore-0.9.4 frameworks/sproutcore/validators/not_empty.js
sproutcore-0.9.7 frameworks/sproutcore/validators/not_empty.js
sproutcore-0.9.6 frameworks/sproutcore/validators/not_empty.js