UNPKG

1.34 kBJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5Object.defineProperty(exports, "__esModule", { value: true });
6exports.IsFQDN = exports.isFQDN = exports.IS_FQDN = void 0;
7const ValidateBy_1 = require("../common/ValidateBy");
8const isFQDN_1 = __importDefault(require("validator/lib/isFQDN"));
9exports.IS_FQDN = 'isFqdn';
10/**
11 * Checks if the string is a fully qualified domain name (e.g. domain.com).
12 * If given value is not a string, then it returns false.
13 */
14function isFQDN(value, options) {
15 return typeof value === 'string' && (0, isFQDN_1.default)(value, options);
16}
17exports.isFQDN = isFQDN;
18/**
19 * Checks if the string is a fully qualified domain name (e.g. domain.com).
20 * If given value is not a string, then it returns false.
21 */
22function IsFQDN(options, validationOptions) {
23 return (0, ValidateBy_1.ValidateBy)({
24 name: exports.IS_FQDN,
25 constraints: [options],
26 validator: {
27 validate: (value, args) => isFQDN(value, args.constraints[0]),
28 defaultMessage: (0, ValidateBy_1.buildMessage)(eachPrefix => eachPrefix + '$property must be a valid domain name', validationOptions),
29 },
30 }, validationOptions);
31}
32exports.IsFQDN = IsFQDN;
33//# sourceMappingURL=IsFQDN.js.map
\No newline at end of file