este-library-oldschool
Version:
Library for github.com/steida/este.git
60 lines (54 loc) • 1.85 kB
JavaScript
// Generated by github.com/steida/coffee2closure 900.1.18
/**
@fileoverview Validate inexistence value in list.
*/
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,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
goog.provide('este.validators.Exclusion');
goog.provide('este.validators.exclusion');
goog.require('este.validators.Base');
/**
@param {!Array} exclusion
@param {function(): string=} getMsg
@constructor
@extends {este.validators.Base}
*/
este.validators.Exclusion = function(exclusion1, getMsg) {
this.exclusion = exclusion1;
este.validators.Exclusion.superClass_.constructor.call(this, getMsg);
}
extend(este.validators.Exclusion, superClass);
/**
@type {Array}
@protected
*/
este.validators.Exclusion.prototype.exclusion = null;
/**
@override
*/
este.validators.Exclusion.prototype.validate = function() {
var ref;
return ref = this.value, indexOf.call(this.exclusion, ref) < 0;
};
/**
@override
*/
este.validators.Exclusion.prototype.getMsg = function() {
/**
@desc Exclusion validator message.
*/
return este.validators.Exclusion.MSG_VALIDATOR_EXCLUSION = goog.getMsg('\'{$value}\' is not allowed.', {
'value': this.value
});
};
/**
@param {!Array} exclusion
@param {function(): string=} getMsg
@return {function(): este.validators.Exclusion}
*/
este.validators.exclusion = function(exclusion, getMsg) {
return function() {
return new este.validators.Exclusion(exclusion, getMsg);
};
};