UNPKG

jaywalk

Version:
38 lines 1.37 kB
"use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var validator = require('validator'); var string_1 = require('./string'); var utils_1 = require('../utils'); var Email = (function (_super) { __extends(Email, _super); function Email(options) { if (options === void 0) { options = {}; } _super.call(this, options); this.type = 'Email'; this._tests.push(isEmail); } Email.prototype._isType = function (value, path, context) { return utils_1.wrapIsType(this, value, path, context, _super.prototype._isType, function (value) { if (validator.isEmail(value)) { return 1; } throw context.error(path, 'Email', 'type', 'Email', value); }); }; Email.prototype._extend = function (options) { return _super.prototype._extend.call(this, options); }; return Email; }(string_1.String)); exports.Email = Email; function isEmail(value, path, context, next) { if (!validator.isEmail(value)) { throw context.error(path, 'Email', 'type', 'Email', value); } return next(value); } //# sourceMappingURL=email.js.map