I" (function() { 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.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; App.Validators.Length = (function(superClass) { extend(Length, superClass); function Length() { Length.__super__.constructor.apply(this, arguments); } Length.prototype.validate = function() { var message; if (this.val == null) { return true; } message = (this._range()[0] != null) && (this._range()[1] != null) && this._range()[0] === this._range()[1] && this.val.length !== this._range()[0] ? this._selectErrorMessage('wrong_length', this._range()[0]) : (this._range()[0] != null) && this.val.length < this._range()[0] ? this._selectErrorMessage('too_short', this._range()[0]) : (this._range()[1] != null) && this.val.length > this._range()[1] ? this._selectErrorMessage('too_long', this._range()[1]) : null; return this.obj.addErrorMessage(message, { "for": this.attr }); }; Length.prototype._range = function() { var from, to; from = this.opts.minimum || this.opts.is || ((this.opts.within != null) && this.opts.within[0]) || null; to = this.opts.maximum || this.opts.is || ((this.opts.within != null) && this.opts.within[1]) || null; return [from, to]; }; Length.prototype._selectErrorMessage = function(msg, val) { var i, len, message, ref, variant; if (val === 1) { return App.I18n[App.Env.loco.getLocale()].errors.messages[msg].one; } message = null; ref = ['few', 'many']; for (i = 0, len = ref.length; i < len; i++) { variant = ref[i]; if (this._checkVariant(variant, val)) { message = App.I18n[App.Env.loco.getLocale()].errors.messages[msg][variant]; break; } } if (message == null) { message = App.I18n[App.Env.loco.getLocale()].errors.messages[msg].other; } if (/%{count}/.exec(message)) { message = message.replace('%{count}', val); } return message; }; Length.prototype._checkVariant = function(variant, val) { if (App.I18n[App.Env.loco.getLocale()].variants[variant] == null) { return; } return App.I18n[App.Env.loco.getLocale()].variants[variant](val); }; return Length; })(App.Validators.Base); }).call(this); :ET