este-library-oldschool
Version:
Library for github.com/steida/este.git
59 lines (53 loc) • 1.72 kB
JavaScript
// Generated by github.com/steida/coffee2closure 900.1.18
/**
@fileoverview Validate string length.
*/
var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.superClass_ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
goog.provide('este.validators.MinLength');
goog.provide('este.validators.minLength');
goog.require('este.validators.Base');
/**
@param {number} minLength
@param {function(): string=} getMsg
@constructor
@extends {este.validators.Base}
*/
este.validators.MinLength = function(minLength1, getMsg) {
this.minLength = minLength1;
este.validators.MinLength.superClass_.constructor.call(this, getMsg);
}
extend(este.validators.MinLength, superClass);
/**
@type {number}
@protected
*/
este.validators.MinLength.prototype.minLength = 0;
/**
@override
*/
este.validators.MinLength.prototype.validate = function() {
goog.asserts.assertString(this.value);
return this.value.length >= this.minLength;
};
/**
@override
*/
este.validators.MinLength.prototype.getMsg = function() {
/**
@desc MinLength validator message.
*/
return este.validators.MinLength.MSG_VALIDATOR_MIN_LENGTH = goog.getMsg('Please enter at least {$minLength} characters.', {
'minLength': this.minLength
});
};
/**
@param {number} minLength
@param {function(): string=} getMsg
@return {function(): este.validators.MinLength}
*/
este.validators.minLength = function(minLength, getMsg) {
return function() {
return new este.validators.MinLength(minLength, getMsg);
};
};