"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isHostValid = exports.isEachUniqueHostValid = exports.isValidContactFromName = exports.isValidContactBody = void 0;
const tslib_1 = require("tslib");
const validator_1 = (0, tslib_1.__importDefault)(require("validator"));
const misc_1 = require("./misc");
const core_utils_1 = require("../core-utils");
const constants_1 = require("../../initializers/constants");
function isHostValid(host) {
    const isURLOptions = {
        require_host: true,
        require_tld: true
    };
    if ((0, core_utils_1.isTestInstance)()) {
        isURLOptions.require_tld = false;
    }
    return (0, misc_1.exists)(host) && validator_1.default.isURL(host, isURLOptions) && host.split('://').length === 1;
}
exports.isHostValid = isHostValid;
function isEachUniqueHostValid(hosts) {
    return (0, misc_1.isArray)(hosts) &&
        hosts.every(host => {
            return isHostValid(host) && hosts.indexOf(host) === hosts.lastIndexOf(host);
        });
}
exports.isEachUniqueHostValid = isEachUniqueHostValid;
function isValidContactBody(value) {
    return (0, misc_1.exists)(value) && validator_1.default.isLength(value, constants_1.CONSTRAINTS_FIELDS.CONTACT_FORM.BODY);
}
exports.isValidContactBody = isValidContactBody;
function isValidContactFromName(value) {
    return (0, misc_1.exists)(value) && validator_1.default.isLength(value, constants_1.CONSTRAINTS_FIELDS.CONTACT_FORM.FROM_NAME);
}
exports.isValidContactFromName = isValidContactFromName;
//# sourceMappingURL=servers.js.map