UNPKG

este-library-oldschool

Version:

Library for github.com/steida/este.git

59 lines (53 loc) 1.72 kB
// 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.MaxLength'); goog.provide('este.validators.maxLength'); goog.require('este.validators.Base'); /** @param {number} maxLength @param {function(): string=} getMsg @constructor @extends {este.validators.Base} */ este.validators.MaxLength = function(maxLength1, getMsg) { this.maxLength = maxLength1; este.validators.MaxLength.superClass_.constructor.call(this, getMsg); } extend(este.validators.MaxLength, superClass); /** @type {number} @protected */ este.validators.MaxLength.prototype.maxLength = 0; /** @override */ este.validators.MaxLength.prototype.validate = function() { goog.asserts.assertString(this.value); return this.value.length <= this.maxLength; }; /** @override */ este.validators.MaxLength.prototype.getMsg = function() { /** @desc MaxLength validator message. */ return este.validators.MaxLength.MSG_VALIDATOR_MAX_LENGTH = goog.getMsg('Please enter no more than {$maxLength} characters.', { 'maxLength': this.maxLength }); }; /** @param {number} maxLength @param {function(): string=} getMsg @return {function(): este.validators.MaxLength} */ este.validators.maxLength = function(maxLength, getMsg) { return function() { return new este.validators.MaxLength(maxLength, getMsg); }; };