typia
Version:
Superfast runtime validators with only one line
21 lines • 1.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._randomFormatIdnEmail = void 0;
const _randomString_1 = require("./_randomString");
const _randomStringLength_1 = require("./_randomStringLength");
const _randomFormatIdnEmail = (props) => {
if ((props === null || props === void 0 ? void 0 : props.minLength) === undefined && (props === null || props === void 0 ? void 0 : props.maxLength) === undefined)
return `${random(10)}@${random(10)}.${random(3)}`;
// `_isFormatIdnEmail` requires a >=2-char TLD (`(…\.)+[^…]{2,}`), so the fixed
// overhead is `@` + domain(1) + `.` + tld(2) = 5 and the local part absorbs the
// requested length; a one-character TLD (the non-idn generator's length path)
// would be rejected by the idn checker on every draw.
return `${(0, _randomStringLength_1._randomSegmentLength)(props, 5, 10, 1)}@${random(1)}.${random(2)}`;
};
exports._randomFormatIdnEmail = _randomFormatIdnEmail;
const random = (length) => (0, _randomString_1._randomString)({
type: "string",
minLength: length,
maxLength: length,
});
//# sourceMappingURL=_randomFormatIdnEmail.js.map