@adobe/alloy 2.17.0 → 2.18.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/libEs5/components/ActivityCollector/configValidators.js +9 -5
- package/libEs5/components/ActivityCollector/utils.js +22 -3
- package/libEs5/components/Audiences/index.js +0 -1
- package/libEs5/components/Context/index.js +2 -2
- package/libEs5/components/DataCollector/index.js +1 -2
- package/libEs5/components/EventMerge/index.js +0 -1
- package/libEs5/components/Identity/configValidators.js +2 -2
- package/libEs5/components/Identity/getIdentity/createGetIdentity.js +8 -5
- package/libEs5/components/Identity/getIdentity/createIdentityRequest.js +5 -2
- package/libEs5/components/MachineLearning/index.js +0 -1
- package/libEs5/components/Personalization/index.js +2 -2
- package/libEs5/components/Privacy/createConsentRequest.js +5 -2
- package/libEs5/components/Privacy/injectSendSetConsentRequest.js +10 -6
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/core/buildAndValidateConfig.js +79 -26
- package/libEs5/core/config/createCoreConfigs.js +3 -3
- package/libEs5/core/createEventManager.js +15 -6
- package/libEs5/core/edgeNetwork/injectSendEdgeNetworkRequest.js +3 -2
- package/libEs5/utils/request/createDataCollectionRequest.js +10 -6
- package/libEs5/utils/request/createRequest.js +5 -1
- package/libEs5/utils/request/createRequestParams.js +53 -0
- package/libEs5/utils/request/index.js +8 -0
- package/libEs5/utils/validation/booleanValidator.js +2 -2
- package/libEs5/utils/validation/callbackValidator.js +2 -2
- package/libEs5/utils/validation/createAnyOfValidator.js +8 -5
- package/libEs5/utils/validation/createArrayOfValidator.js +6 -4
- package/libEs5/utils/validation/createDeprecatedValidator.js +53 -0
- package/libEs5/utils/validation/createLiteralValidator.js +2 -2
- package/libEs5/utils/validation/createMapOfValuesValidator.js +6 -4
- package/libEs5/utils/validation/createMinimumValidator.js +2 -2
- package/libEs5/utils/validation/createNonEmptyValidator.js +3 -3
- package/libEs5/utils/validation/createObjectOfValidator.js +6 -4
- package/libEs5/utils/validation/createUniqueItemsValidator.js +2 -2
- package/libEs5/utils/validation/createUniqueValidator.js +2 -2
- package/libEs5/utils/validation/domainValidator.js +2 -2
- package/libEs5/utils/validation/index.js +54 -45
- package/libEs5/utils/validation/integerValidator.js +2 -2
- package/libEs5/utils/validation/numberValidator.js +2 -2
- package/libEs5/utils/validation/regexpValidator.js +2 -2
- package/libEs5/utils/validation/stringValidator.js +2 -2
- package/libEs5/utils/validation/utils.js +155 -0
- package/libEs6/components/ActivityCollector/configValidators.js +6 -5
- package/libEs6/components/ActivityCollector/utils.js +20 -3
- package/libEs6/components/Audiences/index.js +0 -1
- package/libEs6/components/Context/index.js +3 -3
- package/libEs6/components/DataCollector/index.js +1 -2
- package/libEs6/components/EventMerge/index.js +0 -1
- package/libEs6/components/Identity/configValidators.js +3 -3
- package/libEs6/components/Identity/getIdentity/createGetIdentity.js +7 -5
- package/libEs6/components/Identity/getIdentity/createIdentityRequest.js +6 -2
- package/libEs6/components/MachineLearning/index.js +0 -1
- package/libEs6/components/Personalization/index.js +3 -3
- package/libEs6/components/Privacy/createConsentRequest.js +6 -2
- package/libEs6/components/Privacy/injectSendSetConsentRequest.js +9 -6
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/core/buildAndValidateConfig.js +48 -19
- package/libEs6/core/config/createCoreConfigs.js +4 -4
- package/libEs6/core/createEventManager.js +14 -6
- package/libEs6/core/edgeNetwork/injectSendEdgeNetworkRequest.js +3 -2
- package/libEs6/utils/request/createDataCollectionRequest.js +6 -2
- package/libEs6/utils/request/createRequest.js +6 -1
- package/libEs6/utils/request/createRequestParams.js +43 -0
- package/libEs6/utils/request/index.js +1 -0
- package/libEs6/utils/validation/booleanValidator.js +1 -1
- package/libEs6/utils/validation/callbackValidator.js +1 -1
- package/libEs6/utils/validation/createAnyOfValidator.js +5 -4
- package/libEs6/utils/validation/createArrayOfValidator.js +3 -3
- package/libEs6/utils/validation/createDeprecatedValidator.js +41 -0
- package/libEs6/utils/validation/createLiteralValidator.js +1 -1
- package/libEs6/utils/validation/createMapOfValuesValidator.js +3 -3
- package/libEs6/utils/validation/createMinimumValidator.js +1 -1
- package/libEs6/utils/validation/createNonEmptyValidator.js +1 -1
- package/libEs6/utils/validation/createObjectOfValidator.js +3 -3
- package/libEs6/utils/validation/createUniqueItemsValidator.js +1 -1
- package/libEs6/utils/validation/createUniqueValidator.js +1 -1
- package/libEs6/utils/validation/domainValidator.js +1 -1
- package/libEs6/utils/validation/index.js +84 -13
- package/libEs6/utils/validation/integerValidator.js +1 -1
- package/libEs6/utils/validation/numberValidator.js +1 -1
- package/libEs6/utils/validation/regexpValidator.js +1 -1
- package/libEs6/utils/validation/stringValidator.js +1 -1
- package/libEs6/utils/validation/utils.js +131 -0
- package/package.json +6 -4
- package/libEs5/utils/validation/assertValid.js +0 -22
- package/libEs5/utils/validation/chain.js +0 -76
- package/libEs5/utils/validation/nullSafeChain.js +0 -41
- package/libEs6/utils/validation/assertValid.js +0 -16
- package/libEs6/utils/validation/chain.js +0 -67
- package/libEs6/utils/validation/nullSafeChain.js +0 -32
|
@@ -4,7 +4,7 @@ exports.default = void 0;
|
|
|
4
4
|
|
|
5
5
|
var _isFunction = require("../isFunction");
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _utils = require("./utils");
|
|
8
8
|
|
|
9
9
|
/*
|
|
10
10
|
Copyright 2019 Adobe. All rights reserved.
|
|
@@ -18,7 +18,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
18
18
|
governing permissions and limitations under the License.
|
|
19
19
|
*/
|
|
20
20
|
var _default = function _default(value, path) {
|
|
21
|
-
(0,
|
|
21
|
+
(0, _utils.assertValid)((0, _isFunction.default)(value), value, path, "a function");
|
|
22
22
|
return value;
|
|
23
23
|
};
|
|
24
24
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _utils = require("./utils");
|
|
6
6
|
|
|
7
7
|
var _find = require("../find");
|
|
8
8
|
|
|
@@ -18,17 +18,20 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
18
18
|
governing permissions and limitations under the License.
|
|
19
19
|
*/
|
|
20
20
|
var _default = function _default(validators, message) {
|
|
21
|
-
return function (value, path) {
|
|
21
|
+
return function anyOf(value, path) {
|
|
22
|
+
var _this = this;
|
|
23
|
+
|
|
24
|
+
var newValue;
|
|
22
25
|
var valid = (0, _find.default)(validators, function (validator) {
|
|
23
26
|
try {
|
|
24
|
-
validator(value, path);
|
|
27
|
+
newValue = validator.call(_this, value, path);
|
|
25
28
|
return true;
|
|
26
29
|
} catch (e) {
|
|
27
30
|
return false;
|
|
28
31
|
}
|
|
29
32
|
});
|
|
30
|
-
(0,
|
|
31
|
-
return
|
|
33
|
+
(0, _utils.assertValid)(valid, value, path, message);
|
|
34
|
+
return newValue;
|
|
32
35
|
};
|
|
33
36
|
};
|
|
34
37
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _utils = require("./utils");
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
8
|
Copyright 2019 Adobe. All rights reserved.
|
|
@@ -16,12 +16,14 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
16
16
|
governing permissions and limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
var _default = function _default(elementValidator) {
|
|
19
|
-
return function (value, path) {
|
|
20
|
-
|
|
19
|
+
return function arrayOf(value, path) {
|
|
20
|
+
var _this = this;
|
|
21
|
+
|
|
22
|
+
(0, _utils.assertValid)(Array.isArray(value), value, path, "an array");
|
|
21
23
|
var errors = [];
|
|
22
24
|
var validatedArray = value.map(function (subValue, i) {
|
|
23
25
|
try {
|
|
24
|
-
return elementValidator(subValue, path + "[" + i + "]");
|
|
26
|
+
return elementValidator.call(_this, subValue, path + "[" + i + "]", value);
|
|
25
27
|
} catch (e) {
|
|
26
28
|
errors.push(e.message);
|
|
27
29
|
return undefined;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
|
|
5
|
+
var _isObject = require("../isObject");
|
|
6
|
+
|
|
7
|
+
var _utils = require("./utils");
|
|
8
|
+
|
|
9
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
10
|
+
|
|
11
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
12
|
+
|
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14
|
+
|
|
15
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
|
+
|
|
17
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
18
|
+
|
|
19
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
20
|
+
|
|
21
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
22
|
+
|
|
23
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
24
|
+
|
|
25
|
+
var _default = function _default(oldField, oldSchema, newField) {
|
|
26
|
+
return function deprecated(value, path) {
|
|
27
|
+
(0, _utils.assertValid)((0, _isObject.default)(value), value, path, "an object");
|
|
28
|
+
|
|
29
|
+
var oldValue = value[oldField],
|
|
30
|
+
newValue = value[newField],
|
|
31
|
+
otherValues = _objectWithoutProperties(value, [oldField, newField].map(_toPropertyKey));
|
|
32
|
+
|
|
33
|
+
var validatedOldValue = oldSchema(oldValue, path);
|
|
34
|
+
|
|
35
|
+
if (validatedOldValue !== undefined) {
|
|
36
|
+
var message = "The field '" + oldField + "' is deprecated. Use '" + newField + "' instead.";
|
|
37
|
+
|
|
38
|
+
if (path) {
|
|
39
|
+
message = "'" + path + "': " + message;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (newValue !== undefined && newValue !== validatedOldValue) {
|
|
43
|
+
throw new Error(message);
|
|
44
|
+
} else if (this && this.logger) {
|
|
45
|
+
this.logger.warn(message);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return _objectSpread(_defineProperty({}, newField, newValue || validatedOldValue), otherValues);
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
exports.default = _default;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _utils = require("./utils");
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
8
|
Copyright 2020 Adobe. All rights reserved.
|
|
@@ -17,7 +17,7 @@ governing permissions and limitations under the License.
|
|
|
17
17
|
*/
|
|
18
18
|
var _default = function _default(literalValue) {
|
|
19
19
|
return function (value, path) {
|
|
20
|
-
(0,
|
|
20
|
+
(0, _utils.assertValid)(value === literalValue, value, path, "" + literalValue);
|
|
21
21
|
return value;
|
|
22
22
|
};
|
|
23
23
|
};
|
|
@@ -4,7 +4,7 @@ exports.default = void 0;
|
|
|
4
4
|
|
|
5
5
|
var _isObject = require("../isObject");
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _utils = require("./utils");
|
|
8
8
|
|
|
9
9
|
/*
|
|
10
10
|
Copyright 2020 Adobe. All rights reserved.
|
|
@@ -18,8 +18,10 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
18
18
|
governing permissions and limitations under the License.
|
|
19
19
|
*/
|
|
20
20
|
var _default = function _default(valueValidator) {
|
|
21
|
-
return function (value, path) {
|
|
22
|
-
|
|
21
|
+
return function mapOfValues(value, path) {
|
|
22
|
+
var _this = this;
|
|
23
|
+
|
|
24
|
+
(0, _utils.assertValid)((0, _isObject.default)(value), value, path, "an object");
|
|
23
25
|
var errors = [];
|
|
24
26
|
var validatedObject = {};
|
|
25
27
|
Object.keys(value).forEach(function (subKey) {
|
|
@@ -27,7 +29,7 @@ var _default = function _default(valueValidator) {
|
|
|
27
29
|
var subPath = path ? path + "." + subKey : subKey;
|
|
28
30
|
|
|
29
31
|
try {
|
|
30
|
-
var validatedValue = valueValidator(subValue, subPath);
|
|
32
|
+
var validatedValue = valueValidator.call(_this, subValue, subPath);
|
|
31
33
|
|
|
32
34
|
if (validatedValue !== undefined) {
|
|
33
35
|
validatedObject[subKey] = validatedValue;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _utils = require("./utils");
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
8
|
Copyright 2019 Adobe. All rights reserved.
|
|
@@ -17,7 +17,7 @@ governing permissions and limitations under the License.
|
|
|
17
17
|
*/
|
|
18
18
|
var _default = function _default(typeName, minimum) {
|
|
19
19
|
return function (value, path) {
|
|
20
|
-
(0,
|
|
20
|
+
(0, _utils.assertValid)(value >= minimum, value, path, typeName + " greater than or equal to " + minimum);
|
|
21
21
|
return value;
|
|
22
22
|
};
|
|
23
23
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _utils = require("./utils");
|
|
6
6
|
|
|
7
7
|
var _isObject = require("../isObject");
|
|
8
8
|
|
|
@@ -22,9 +22,9 @@ governing permissions and limitations under the License.
|
|
|
22
22
|
var _default = function _default(message) {
|
|
23
23
|
return function (value, path) {
|
|
24
24
|
if ((0, _isObject.default)(value)) {
|
|
25
|
-
(0,
|
|
25
|
+
(0, _utils.assertValid)(!(0, _isEmptyObject.default)(value), value, path, message);
|
|
26
26
|
} else {
|
|
27
|
-
(0,
|
|
27
|
+
(0, _utils.assertValid)(value.length > 0, value, path, message);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
return value;
|
|
@@ -4,7 +4,7 @@ exports.default = void 0;
|
|
|
4
4
|
|
|
5
5
|
var _isObject = require("../isObject");
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _utils = require("./utils");
|
|
8
8
|
|
|
9
9
|
/*
|
|
10
10
|
Copyright 2020 Adobe. All rights reserved.
|
|
@@ -18,8 +18,10 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
18
18
|
governing permissions and limitations under the License.
|
|
19
19
|
*/
|
|
20
20
|
var _default = function _default(schema) {
|
|
21
|
-
return function (value, path) {
|
|
22
|
-
|
|
21
|
+
return function objectOf(value, path) {
|
|
22
|
+
var _this = this;
|
|
23
|
+
|
|
24
|
+
(0, _utils.assertValid)((0, _isObject.default)(value), value, path, "an object");
|
|
23
25
|
var errors = [];
|
|
24
26
|
var validatedObject = {};
|
|
25
27
|
Object.keys(schema).forEach(function (subKey) {
|
|
@@ -28,7 +30,7 @@ var _default = function _default(schema) {
|
|
|
28
30
|
var subPath = path ? path + "." + subKey : subKey;
|
|
29
31
|
|
|
30
32
|
try {
|
|
31
|
-
var validatedValue = subSchema(subValue, subPath);
|
|
33
|
+
var validatedValue = subSchema.call(_this, subValue, subPath);
|
|
32
34
|
|
|
33
35
|
if (validatedValue !== undefined) {
|
|
34
36
|
validatedObject[subKey] = validatedValue;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _utils = require("./utils");
|
|
6
6
|
|
|
7
7
|
var _isUnique = require("../isUnique");
|
|
8
8
|
|
|
@@ -19,7 +19,7 @@ governing permissions and limitations under the License.
|
|
|
19
19
|
*/
|
|
20
20
|
var _default = function _default() {
|
|
21
21
|
return function (value, path) {
|
|
22
|
-
(0,
|
|
22
|
+
(0, _utils.assertValid)((0, _isUnique.default)(value), value, path, "array values to be unique");
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _utils = require("./utils");
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
8
|
Copyright 2019 Adobe. All rights reserved.
|
|
@@ -18,7 +18,7 @@ governing permissions and limitations under the License.
|
|
|
18
18
|
var _default = function _default() {
|
|
19
19
|
var values = [];
|
|
20
20
|
return function (value, path) {
|
|
21
|
-
(0,
|
|
21
|
+
(0, _utils.assertValid)(values.indexOf(value) === -1, value, path, "a unique value across instances");
|
|
22
22
|
values.push(value);
|
|
23
23
|
return value;
|
|
24
24
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _utils = require("./utils");
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
8
|
Copyright 2019 Adobe. All rights reserved.
|
|
@@ -18,7 +18,7 @@ governing permissions and limitations under the License.
|
|
|
18
18
|
var DOMAIN_REGEX = /^[a-z0-9.-]{1,}$/i;
|
|
19
19
|
|
|
20
20
|
var _default = function _default(value, path) {
|
|
21
|
-
(0,
|
|
21
|
+
(0, _utils.assertValid)(DOMAIN_REGEX.test(value), value, path, "a valid domain");
|
|
22
22
|
return value;
|
|
23
23
|
};
|
|
24
24
|
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.string = exports.objectOf = exports.number = exports.mapOfValues = exports.literal = exports.enumOf = exports.callback = exports.boolean = exports.arrayOf = exports.anything = exports.anyOf = void 0;
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
var _nullSafeChain = require("./nullSafeChain");
|
|
5
|
+
var _utils = require("./utils");
|
|
8
6
|
|
|
9
7
|
var _booleanValidator = require("./booleanValidator");
|
|
10
8
|
|
|
@@ -14,6 +12,8 @@ var _createArrayOfValidator = require("./createArrayOfValidator");
|
|
|
14
12
|
|
|
15
13
|
var _createDefaultValidator = require("./createDefaultValidator");
|
|
16
14
|
|
|
15
|
+
var _createDeprecatedValidator = require("./createDeprecatedValidator");
|
|
16
|
+
|
|
17
17
|
var _createLiteralValidator = require("./createLiteralValidator");
|
|
18
18
|
|
|
19
19
|
var _createMapOfValuesValidator = require("./createMapOfValuesValidator");
|
|
@@ -44,108 +44,103 @@ var _requiredValidator = require("./requiredValidator");
|
|
|
44
44
|
|
|
45
45
|
var _stringValidator = require("./stringValidator");
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
54
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
55
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
56
|
-
governing permissions and limitations under the License.
|
|
57
|
-
*/
|
|
58
|
-
// See comments on chain and nullSafeChain to understand what is going on here.
|
|
47
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
48
|
+
|
|
49
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
50
|
+
|
|
51
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
52
|
+
|
|
59
53
|
// The base validator does no validation and just returns the value unchanged
|
|
60
54
|
var base = function base(value) {
|
|
61
55
|
return value;
|
|
62
|
-
}; // The 'default' and '
|
|
63
|
-
// Don't use the nullSafeChain
|
|
56
|
+
}; // The 'default', 'required', and 'deprecated' methods are available after any
|
|
57
|
+
// data-type method. Don't use the nullSafeChain on 'default' or 'required'
|
|
58
|
+
// because they need to handle the null or undefined case
|
|
64
59
|
|
|
65
60
|
|
|
66
61
|
base.default = function _default(defaultValue) {
|
|
67
|
-
return (0,
|
|
62
|
+
return (0, _utils.chain)(this, (0, _createDefaultValidator.default)(defaultValue));
|
|
68
63
|
};
|
|
69
64
|
|
|
70
65
|
base.required = function required() {
|
|
71
|
-
return (0,
|
|
66
|
+
return (0, _utils.chain)(this, _requiredValidator.default);
|
|
72
67
|
}; // helper validators
|
|
73
68
|
|
|
74
69
|
|
|
75
70
|
var domain = function domain() {
|
|
76
|
-
return (0,
|
|
71
|
+
return (0, _utils.nullSafeChain)(this, _domainValidator.default);
|
|
77
72
|
};
|
|
78
73
|
|
|
79
74
|
var minimumInteger = function minimumInteger(minValue) {
|
|
80
|
-
return (0,
|
|
75
|
+
return (0, _utils.nullSafeChain)(this, (0, _createMinimumValidator.default)("an integer", minValue));
|
|
81
76
|
};
|
|
82
77
|
|
|
83
78
|
var minimumNumber = function minimumNumber(minValue) {
|
|
84
|
-
return (0,
|
|
79
|
+
return (0, _utils.nullSafeChain)(this, (0, _createMinimumValidator.default)("a number", minValue));
|
|
85
80
|
};
|
|
86
81
|
|
|
87
82
|
var integer = function integer() {
|
|
88
|
-
return (0,
|
|
83
|
+
return (0, _utils.nullSafeChain)(this, _integerValidator.default, {
|
|
89
84
|
minimum: minimumInteger
|
|
90
85
|
});
|
|
91
86
|
};
|
|
92
87
|
|
|
93
88
|
var nonEmptyString = function nonEmptyString() {
|
|
94
|
-
return (0,
|
|
89
|
+
return (0, _utils.nullSafeChain)(this, (0, _createNonEmptyValidator.default)("a non-empty string"));
|
|
95
90
|
};
|
|
96
91
|
|
|
97
92
|
var nonEmptyArray = function nonEmptyArray() {
|
|
98
|
-
return (0,
|
|
93
|
+
return (0, _utils.nullSafeChain)(this, (0, _createNonEmptyValidator.default)("a non-empty array"));
|
|
99
94
|
};
|
|
100
95
|
|
|
101
96
|
var nonEmptyObject = function nonEmptyObject() {
|
|
102
|
-
return (0,
|
|
97
|
+
return (0, _utils.nullSafeChain)(this, (0, _createNonEmptyValidator.default)("a non-empty object"));
|
|
103
98
|
};
|
|
104
99
|
|
|
105
100
|
var regexp = function regexp() {
|
|
106
|
-
return (0,
|
|
101
|
+
return (0, _utils.nullSafeChain)(this, _regexpValidator.default);
|
|
107
102
|
};
|
|
108
103
|
|
|
109
104
|
var unique = function createUnique() {
|
|
110
|
-
return (0,
|
|
105
|
+
return (0, _utils.nullSafeChain)(this, (0, _createUniqueValidator.default)());
|
|
111
106
|
};
|
|
112
107
|
|
|
113
108
|
var uniqueItems = function createUniqueItems() {
|
|
114
|
-
return (0,
|
|
109
|
+
return (0, _utils.nullSafeChain)(this, (0, _createUniqueItemsValidator.default)());
|
|
115
110
|
}; // top-level validators. These are the first functions that are called to create a validator.
|
|
116
111
|
|
|
117
112
|
|
|
118
113
|
var anyOf = function anyOf(validators, message) {
|
|
119
114
|
// use chain here because we don't want to accept null or undefined unless at least
|
|
120
115
|
// one of the validators accept null or undefined.
|
|
121
|
-
return (0,
|
|
116
|
+
return (0, _utils.chain)(this, (0, _createAnyOfValidator.default)(validators, message));
|
|
122
117
|
};
|
|
123
118
|
|
|
124
119
|
var anything = function anything() {
|
|
125
|
-
return
|
|
120
|
+
return this;
|
|
126
121
|
};
|
|
127
122
|
|
|
128
123
|
var arrayOf = function arrayOf(elementValidator) {
|
|
129
|
-
return (0,
|
|
124
|
+
return (0, _utils.nullSafeChain)(this, (0, _createArrayOfValidator.default)(elementValidator), {
|
|
130
125
|
nonEmpty: nonEmptyArray,
|
|
131
126
|
uniqueItems: uniqueItems
|
|
132
127
|
});
|
|
133
128
|
};
|
|
134
129
|
|
|
135
130
|
var boolean = function boolean() {
|
|
136
|
-
return (0,
|
|
131
|
+
return (0, _utils.nullSafeChain)(this, _booleanValidator.default);
|
|
137
132
|
};
|
|
138
133
|
|
|
139
134
|
var callback = function callback() {
|
|
140
|
-
return (0,
|
|
135
|
+
return (0, _utils.nullSafeChain)(this, _callbackValidator.default);
|
|
141
136
|
};
|
|
142
137
|
|
|
143
138
|
var literal = function literal(literalValue) {
|
|
144
|
-
return (0,
|
|
139
|
+
return (0, _utils.nullSafeChain)(this, (0, _createLiteralValidator.default)(literalValue));
|
|
145
140
|
};
|
|
146
141
|
|
|
147
142
|
var number = function number() {
|
|
148
|
-
return (0,
|
|
143
|
+
return (0, _utils.nullSafeChain)(this, _numberValidator.default, {
|
|
149
144
|
minimum: minimumNumber,
|
|
150
145
|
integer: integer,
|
|
151
146
|
unique: unique
|
|
@@ -153,24 +148,38 @@ var number = function number() {
|
|
|
153
148
|
};
|
|
154
149
|
|
|
155
150
|
var mapOfValues = function mapOfValues(valuesValidator) {
|
|
156
|
-
return (0,
|
|
151
|
+
return (0, _utils.nullSafeChain)(this, (0, _createMapOfValuesValidator.default)(valuesValidator), {
|
|
157
152
|
nonEmpty: nonEmptyObject
|
|
158
153
|
});
|
|
159
154
|
};
|
|
160
155
|
|
|
161
|
-
var
|
|
162
|
-
|
|
163
|
-
|
|
156
|
+
var createObjectOfAdditionalProperties = function createObjectOfAdditionalProperties(schema) {
|
|
157
|
+
return {
|
|
158
|
+
noUnknownFields: function noUnknownFields() {
|
|
159
|
+
return (0, _utils.nullSafeChain)(this, (0, _createNoUnknownFieldsValidator.default)(schema));
|
|
160
|
+
},
|
|
161
|
+
nonEmpty: nonEmptyObject,
|
|
162
|
+
concat: function concat(otherObjectOfValidator) {
|
|
163
|
+
// combine the schema so that noUnknownFields, and concat have the combined schema
|
|
164
|
+
var newSchema = _objectSpread(_objectSpread({}, schema), otherObjectOfValidator.schema);
|
|
165
|
+
|
|
166
|
+
return (0, _utils.nullSafeChain)(this, otherObjectOfValidator, createObjectOfAdditionalProperties(newSchema));
|
|
167
|
+
},
|
|
168
|
+
deprecated: function deprecated(oldField, oldSchema, newField) {
|
|
169
|
+
// Run the deprecated validator first so that the deprecated field is removed
|
|
170
|
+
// before the objectOf validator runs.
|
|
171
|
+
return (0, _utils.reverseNullSafeChainJoinErrors)(this, (0, _createDeprecatedValidator.default)(oldField, oldSchema, newField));
|
|
172
|
+
},
|
|
173
|
+
schema: schema
|
|
164
174
|
};
|
|
175
|
+
};
|
|
165
176
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
nonEmpty: nonEmptyObject
|
|
169
|
-
});
|
|
177
|
+
var objectOf = function objectOf(schema) {
|
|
178
|
+
return (0, _utils.nullSafeChain)(this, (0, _createObjectOfValidator.default)(schema), createObjectOfAdditionalProperties(schema));
|
|
170
179
|
};
|
|
171
180
|
|
|
172
181
|
var string = function string() {
|
|
173
|
-
return (0,
|
|
182
|
+
return (0, _utils.nullSafeChain)(this, _stringValidator.default, {
|
|
174
183
|
regexp: regexp,
|
|
175
184
|
domain: domain,
|
|
176
185
|
nonEmpty: nonEmptyString,
|
|
@@ -4,7 +4,7 @@ exports.default = void 0;
|
|
|
4
4
|
|
|
5
5
|
var _isInteger = require("../isInteger");
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _utils = require("./utils");
|
|
8
8
|
|
|
9
9
|
/*
|
|
10
10
|
Copyright 2019 Adobe. All rights reserved.
|
|
@@ -18,7 +18,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
18
18
|
governing permissions and limitations under the License.
|
|
19
19
|
*/
|
|
20
20
|
var _default = function _default(value, path) {
|
|
21
|
-
(0,
|
|
21
|
+
(0, _utils.assertValid)((0, _isInteger.default)(value), value, path, "an integer");
|
|
22
22
|
return value;
|
|
23
23
|
};
|
|
24
24
|
|
|
@@ -4,7 +4,7 @@ exports.default = void 0;
|
|
|
4
4
|
|
|
5
5
|
var _isNumber = require("../isNumber");
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _utils = require("./utils");
|
|
8
8
|
|
|
9
9
|
/*
|
|
10
10
|
Copyright 2019 Adobe. All rights reserved.
|
|
@@ -18,7 +18,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
18
18
|
governing permissions and limitations under the License.
|
|
19
19
|
*/
|
|
20
20
|
var _default = function _default(value, path) {
|
|
21
|
-
(0,
|
|
21
|
+
(0, _utils.assertValid)((0, _isNumber.default)(value), value, path, "a number");
|
|
22
22
|
return value;
|
|
23
23
|
};
|
|
24
24
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _utils = require("./utils");
|
|
6
6
|
|
|
7
7
|
var _isValidRegExp = require("../isValidRegExp");
|
|
8
8
|
|
|
@@ -18,7 +18,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
18
18
|
governing permissions and limitations under the License.
|
|
19
19
|
*/
|
|
20
20
|
var _default = function _default(value, path) {
|
|
21
|
-
(0,
|
|
21
|
+
(0, _utils.assertValid)((0, _isValidRegExp.default)(value), value, path, "a regular expression");
|
|
22
22
|
return value;
|
|
23
23
|
};
|
|
24
24
|
|
|
@@ -4,7 +4,7 @@ exports.default = void 0;
|
|
|
4
4
|
|
|
5
5
|
var _isString = require("../isString");
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _utils = require("./utils");
|
|
8
8
|
|
|
9
9
|
/*
|
|
10
10
|
Copyright 2019 Adobe. All rights reserved.
|
|
@@ -18,7 +18,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
18
18
|
governing permissions and limitations under the License.
|
|
19
19
|
*/
|
|
20
20
|
var _default = function _default(value, path) {
|
|
21
|
-
(0,
|
|
21
|
+
(0, _utils.assertValid)((0, _isString.default)(value), value, path, "a string");
|
|
22
22
|
return value;
|
|
23
23
|
};
|
|
24
24
|
|