UNPKG

offensive

Version:

Fast and boilerplate-free precondition checks for javascript.

27 lines (26 loc) 862 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EmailAssertion = void 0; var model_1 = require("../../model"); require("../matches"); var EMAIL_REGEXP = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/i; /** * @author Maciej Chałapuk (maciej@chalapuk.pl) */ var EmailAssertion = /** @class */ (function () { function EmailAssertion() { } EmailAssertion.prototype.assert = function (varName, testedValue, contract) { return { get success() { return contract(varName, testedValue).matches(EMAIL_REGEXP).success; }, get message() { return new model_1.StandardMessage(varName, 'be an email', testedValue); }, }; }; return EmailAssertion; }()); exports.EmailAssertion = EmailAssertion; exports.default = EmailAssertion;