UNPKG

assertthat

Version:
18 lines (17 loc) 740 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.assertStringIsMatchingRegExp = void 0; const errors_1 = require("../../errors"); const prettyPrint_1 = require("../../prettyPrint/typeAware/prettyPrint"); const defekt_1 = require("defekt"); const assertStringIsMatchingRegExp = function (actual, expected) { if (expected.test(actual)) { return (0, defekt_1.value)(); } return (0, defekt_1.error)(new errors_1.AssertionFailed({ message: 'The string is not matching the expected regex.', actual: (0, prettyPrint_1.prettyPrint)(actual), expected: `To match:\n${expected.toString()}` })); }; exports.assertStringIsMatchingRegExp = assertStringIsMatchingRegExp;