este-library-oldschool
Version:
Library for github.com/steida/este.git
60 lines (54 loc) • 1.88 kB
JavaScript
// Generated by github.com/steida/coffee2closure 900.1.18
/**
@fileoverview Validate existence 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.Inclusion');
goog.provide('este.validators.inclusion');
goog.require('este.validators.Base');
/**
@param {!Array} inclusion
@param {function(): string=} getMsg
@constructor
@extends {este.validators.Base}
*/
este.validators.Inclusion = function(inclusion1, getMsg) {
this.inclusion = inclusion1;
este.validators.Inclusion.superClass_.constructor.call(this, getMsg);
}
extend(este.validators.Inclusion, superClass);
/**
@type {Array}
@protected
*/
este.validators.Inclusion.prototype.inclusion = null;
/**
@override
*/
este.validators.Inclusion.prototype.validate = function() {
var ref;
return ref = this.value, indexOf.call(this.inclusion, ref) >= 0;
};
/**
@override
*/
este.validators.Inclusion.prototype.getMsg = function() {
/**
@desc Inclusion validator message.
*/
return este.validators.Inclusion.MSG_VALIDATOR_INCLUSION = goog.getMsg('Please enter one of these values: {$inclusion}.', {
'inclusion': this.inclusion.join(', ')
});
};
/**
@param {!Array} inclusion
@param {function(): string=} getMsg
@return {function(): este.validators.Inclusion}
*/
este.validators.inclusion = function(inclusion, getMsg) {
return function() {
return new este.validators.Inclusion(inclusion, getMsg);
};
};