este-library-oldschool
Version:
Library for github.com/steida/este.git
49 lines (44 loc) • 1.47 kB
JavaScript
// Generated by github.com/steida/coffee2closure 900.1.18
/**
@fileoverview Validate string email format.
*/
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.Email');
goog.provide('este.validators.email');
goog.require('este.validators.Base');
goog.require('goog.format.EmailAddress');
/**
@param {function(): string=} getMsg
@constructor
@extends {este.validators.Base}
*/
este.validators.Email = function(getMsg) {
este.validators.Email.superClass_.constructor.call(this, getMsg);
}
extend(este.validators.Email, superClass);
/**
@override
*/
este.validators.Email.prototype.validate = function() {
goog.asserts.assertString(this.value);
return goog.format.EmailAddress.isValidAddress(this.value);
};
/**
@override
*/
este.validators.Email.prototype.getMsg = function() {
/**
@desc Email validator message.
*/
return este.validators.Email.MSG_VALIDATOR_EMAIL = goog.getMsg('Please enter a valid email address.');
};
/**
@param {function(): string=} getMsg
@return {function(): este.validators.Email}
*/
este.validators.email = function(getMsg) {
return function() {
return new este.validators.Email(getMsg);
};
};