UNPKG

1.05 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.IsDefined = exports.isDefined = exports.IS_DEFINED = void 0;
4const ValidateBy_1 = require("./ValidateBy");
5const ValidationTypes_1 = require("../../validation/ValidationTypes");
6// isDefined is (yet) a special case
7exports.IS_DEFINED = ValidationTypes_1.ValidationTypes.IS_DEFINED;
8/**
9 * Checks if value is defined (!== undefined, !== null).
10 */
11function isDefined(value) {
12 return value !== undefined && value !== null;
13}
14exports.isDefined = isDefined;
15/**
16 * Checks if value is defined (!== undefined, !== null).
17 */
18function IsDefined(validationOptions) {
19 return (0, ValidateBy_1.ValidateBy)({
20 name: exports.IS_DEFINED,
21 validator: {
22 validate: (value) => isDefined(value),
23 defaultMessage: (0, ValidateBy_1.buildMessage)(eachPrefix => eachPrefix + '$property should not be null or undefined', validationOptions),
24 },
25 }, validationOptions);
26}
27exports.IsDefined = IsDefined;
28//# sourceMappingURL=IsDefined.js.map
\No newline at end of file