este-library-oldschool
Version:
Library for github.com/steida/este.git
57 lines (51 loc) • 1.6 kB
JavaScript
// Generated by github.com/steida/coffee2closure 900.1.18
/**
@fileoverview Validate string with regex.
*/
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.Format');
goog.provide('este.validators.format');
goog.require('este.validators.Base');
/**
@param {RegExp} regexp
@param {function(): string=} getMsg
@constructor
@extends {este.validators.Base}
*/
este.validators.Format = function(regexp1, getMsg) {
this.regexp = regexp1;
este.validators.Format.superClass_.constructor.call(this, getMsg);
}
extend(este.validators.Format, superClass);
/**
@type {RegExp}
@protected
*/
este.validators.Format.prototype.regexp = null;
/**
@override
*/
este.validators.Format.prototype.validate = function() {
goog.asserts.assertString(this.value);
return this.regexp.test(this.value);
};
/**
@override
*/
este.validators.Format.prototype.getMsg = function() {
/**
@desc Format validator message.
*/
return este.validators.Format.MSG_VALIDATOR_FORMAT = goog.getMsg('Please enter a value in correct format.');
};
/**
@param {RegExp} regexp
@param {function(): string=} getMsg
@return {function(): este.validators.Format}
*/
este.validators.format = function(regexp, getMsg) {
return function() {
return new este.validators.Format(regexp, getMsg);
};
};