typia
Version:
Superfast runtime validators with only one line
21 lines • 1.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._randomFormatRegex = void 0;
const _randomString_1 = require("./_randomString");
const _randomStringLength_1 = require("./_randomStringLength");
const _randomFormatRegex = (props) => {
if ((props === null || props === void 0 ? void 0 : props.minLength) === undefined && (props === null || props === void 0 ? void 0 : props.maxLength) === undefined)
return FIXED;
// Every character `_randomString` emits is a literal in regular expression
// syntax, so a source of any length — including the empty source `new
// RegExp("")` accepts — compiles.
const length = (0, _randomStringLength_1._randomLengthPick)((0, _randomStringLength_1._randomLengthWindow)(props, { minimum: 0, spread: 16 }));
return (0, _randomString_1._randomString)({
type: "string",
minLength: length,
maxLength: length,
});
};
exports._randomFormatRegex = _randomFormatRegex;
const FIXED = "/^(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)$/";
//# sourceMappingURL=_randomFormatRegex.js.map