@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.
Files changed (89) hide show
  1. package/libEs5/components/ActivityCollector/configValidators.js +9 -5
  2. package/libEs5/components/ActivityCollector/utils.js +22 -3
  3. package/libEs5/components/Audiences/index.js +0 -1
  4. package/libEs5/components/Context/index.js +2 -2
  5. package/libEs5/components/DataCollector/index.js +1 -2
  6. package/libEs5/components/EventMerge/index.js +0 -1
  7. package/libEs5/components/Identity/configValidators.js +2 -2
  8. package/libEs5/components/Identity/getIdentity/createGetIdentity.js +8 -5
  9. package/libEs5/components/Identity/getIdentity/createIdentityRequest.js +5 -2
  10. package/libEs5/components/MachineLearning/index.js +0 -1
  11. package/libEs5/components/Personalization/index.js +2 -2
  12. package/libEs5/components/Privacy/createConsentRequest.js +5 -2
  13. package/libEs5/components/Privacy/injectSendSetConsentRequest.js +10 -6
  14. package/libEs5/constants/libraryVersion.js +1 -1
  15. package/libEs5/core/buildAndValidateConfig.js +79 -26
  16. package/libEs5/core/config/createCoreConfigs.js +3 -3
  17. package/libEs5/core/createEventManager.js +15 -6
  18. package/libEs5/core/edgeNetwork/injectSendEdgeNetworkRequest.js +3 -2
  19. package/libEs5/utils/request/createDataCollectionRequest.js +10 -6
  20. package/libEs5/utils/request/createRequest.js +5 -1
  21. package/libEs5/utils/request/createRequestParams.js +53 -0
  22. package/libEs5/utils/request/index.js +8 -0
  23. package/libEs5/utils/validation/booleanValidator.js +2 -2
  24. package/libEs5/utils/validation/callbackValidator.js +2 -2
  25. package/libEs5/utils/validation/createAnyOfValidator.js +8 -5
  26. package/libEs5/utils/validation/createArrayOfValidator.js +6 -4
  27. package/libEs5/utils/validation/createDeprecatedValidator.js +53 -0
  28. package/libEs5/utils/validation/createLiteralValidator.js +2 -2
  29. package/libEs5/utils/validation/createMapOfValuesValidator.js +6 -4
  30. package/libEs5/utils/validation/createMinimumValidator.js +2 -2
  31. package/libEs5/utils/validation/createNonEmptyValidator.js +3 -3
  32. package/libEs5/utils/validation/createObjectOfValidator.js +6 -4
  33. package/libEs5/utils/validation/createUniqueItemsValidator.js +2 -2
  34. package/libEs5/utils/validation/createUniqueValidator.js +2 -2
  35. package/libEs5/utils/validation/domainValidator.js +2 -2
  36. package/libEs5/utils/validation/index.js +54 -45
  37. package/libEs5/utils/validation/integerValidator.js +2 -2
  38. package/libEs5/utils/validation/numberValidator.js +2 -2
  39. package/libEs5/utils/validation/regexpValidator.js +2 -2
  40. package/libEs5/utils/validation/stringValidator.js +2 -2
  41. package/libEs5/utils/validation/utils.js +155 -0
  42. package/libEs6/components/ActivityCollector/configValidators.js +6 -5
  43. package/libEs6/components/ActivityCollector/utils.js +20 -3
  44. package/libEs6/components/Audiences/index.js +0 -1
  45. package/libEs6/components/Context/index.js +3 -3
  46. package/libEs6/components/DataCollector/index.js +1 -2
  47. package/libEs6/components/EventMerge/index.js +0 -1
  48. package/libEs6/components/Identity/configValidators.js +3 -3
  49. package/libEs6/components/Identity/getIdentity/createGetIdentity.js +7 -5
  50. package/libEs6/components/Identity/getIdentity/createIdentityRequest.js +6 -2
  51. package/libEs6/components/MachineLearning/index.js +0 -1
  52. package/libEs6/components/Personalization/index.js +3 -3
  53. package/libEs6/components/Privacy/createConsentRequest.js +6 -2
  54. package/libEs6/components/Privacy/injectSendSetConsentRequest.js +9 -6
  55. package/libEs6/constants/libraryVersion.js +1 -1
  56. package/libEs6/core/buildAndValidateConfig.js +48 -19
  57. package/libEs6/core/config/createCoreConfigs.js +4 -4
  58. package/libEs6/core/createEventManager.js +14 -6
  59. package/libEs6/core/edgeNetwork/injectSendEdgeNetworkRequest.js +3 -2
  60. package/libEs6/utils/request/createDataCollectionRequest.js +6 -2
  61. package/libEs6/utils/request/createRequest.js +6 -1
  62. package/libEs6/utils/request/createRequestParams.js +43 -0
  63. package/libEs6/utils/request/index.js +1 -0
  64. package/libEs6/utils/validation/booleanValidator.js +1 -1
  65. package/libEs6/utils/validation/callbackValidator.js +1 -1
  66. package/libEs6/utils/validation/createAnyOfValidator.js +5 -4
  67. package/libEs6/utils/validation/createArrayOfValidator.js +3 -3
  68. package/libEs6/utils/validation/createDeprecatedValidator.js +41 -0
  69. package/libEs6/utils/validation/createLiteralValidator.js +1 -1
  70. package/libEs6/utils/validation/createMapOfValuesValidator.js +3 -3
  71. package/libEs6/utils/validation/createMinimumValidator.js +1 -1
  72. package/libEs6/utils/validation/createNonEmptyValidator.js +1 -1
  73. package/libEs6/utils/validation/createObjectOfValidator.js +3 -3
  74. package/libEs6/utils/validation/createUniqueItemsValidator.js +1 -1
  75. package/libEs6/utils/validation/createUniqueValidator.js +1 -1
  76. package/libEs6/utils/validation/domainValidator.js +1 -1
  77. package/libEs6/utils/validation/index.js +84 -13
  78. package/libEs6/utils/validation/integerValidator.js +1 -1
  79. package/libEs6/utils/validation/numberValidator.js +1 -1
  80. package/libEs6/utils/validation/regexpValidator.js +1 -1
  81. package/libEs6/utils/validation/stringValidator.js +1 -1
  82. package/libEs6/utils/validation/utils.js +131 -0
  83. package/package.json +6 -4
  84. package/libEs5/utils/validation/assertValid.js +0 -22
  85. package/libEs5/utils/validation/chain.js +0 -76
  86. package/libEs5/utils/validation/nullSafeChain.js +0 -41
  87. package/libEs6/utils/validation/assertValid.js +0 -16
  88. package/libEs6/utils/validation/chain.js +0 -67
  89. 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 _assertValid = require("./assertValid");
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, _assertValid.default)((0, _isFunction.default)(value), value, path, "a function");
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 _assertValid = require("./assertValid");
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, _assertValid.default)(valid, value, path, message);
31
- return value;
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 _assertValid = require("./assertValid");
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
- (0, _assertValid.default)(Array.isArray(value), value, path, "an array");
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 _assertValid = require("./assertValid");
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, _assertValid.default)(value === literalValue, value, path, "" + literalValue);
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 _assertValid = require("./assertValid");
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
- (0, _assertValid.default)((0, _isObject.default)(value), value, path, "an object");
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 _assertValid = require("./assertValid");
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, _assertValid.default)(value >= minimum, value, path, typeName + " greater than or equal to " + minimum);
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 _assertValid = require("./assertValid");
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, _assertValid.default)(!(0, _isEmptyObject.default)(value), value, path, message);
25
+ (0, _utils.assertValid)(!(0, _isEmptyObject.default)(value), value, path, message);
26
26
  } else {
27
- (0, _assertValid.default)(value.length > 0, value, path, message);
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 _assertValid = require("./assertValid");
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
- (0, _assertValid.default)((0, _isObject.default)(value), value, path, "an object");
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 _assertValid = require("./assertValid");
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, _assertValid.default)((0, _isUnique.default)(value), value, path, "array values to be unique");
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 _assertValid = require("./assertValid");
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, _assertValid.default)(values.indexOf(value) === -1, value, path, "a unique value across instances");
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 _assertValid = require("./assertValid");
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, _assertValid.default)(DOMAIN_REGEX.test(value), value, path, "a valid domain");
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 _chain = require("./chain");
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
- Copyright 2020 Adobe. All rights reserved.
49
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
50
- you may not use this file except in compliance with the License. You may obtain a copy
51
- of the License at http://www.apache.org/licenses/LICENSE-2.0
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 'required' methods are available after any data-type method
63
- // Don't use the nullSafeChain because they need to handle the null or undefined case
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, _chain.default)(this, (0, _createDefaultValidator.default)(defaultValue));
62
+ return (0, _utils.chain)(this, (0, _createDefaultValidator.default)(defaultValue));
68
63
  };
69
64
 
70
65
  base.required = function required() {
71
- return (0, _chain.default)(this, _requiredValidator.default);
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, _nullSafeChain.default)(this, _domainValidator.default);
71
+ return (0, _utils.nullSafeChain)(this, _domainValidator.default);
77
72
  };
78
73
 
79
74
  var minimumInteger = function minimumInteger(minValue) {
80
- return (0, _nullSafeChain.default)(this, (0, _createMinimumValidator.default)("an integer", minValue));
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, _nullSafeChain.default)(this, (0, _createMinimumValidator.default)("a number", minValue));
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, _nullSafeChain.default)(this, _integerValidator.default, {
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, _nullSafeChain.default)(this, (0, _createNonEmptyValidator.default)("a non-empty string"));
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, _nullSafeChain.default)(this, (0, _createNonEmptyValidator.default)("a non-empty array"));
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, _nullSafeChain.default)(this, (0, _createNonEmptyValidator.default)("a non-empty object"));
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, _nullSafeChain.default)(this, _regexpValidator.default);
101
+ return (0, _utils.nullSafeChain)(this, _regexpValidator.default);
107
102
  };
108
103
 
109
104
  var unique = function createUnique() {
110
- return (0, _nullSafeChain.default)(this, (0, _createUniqueValidator.default)());
105
+ return (0, _utils.nullSafeChain)(this, (0, _createUniqueValidator.default)());
111
106
  };
112
107
 
113
108
  var uniqueItems = function createUniqueItems() {
114
- return (0, _nullSafeChain.default)(this, (0, _createUniqueItemsValidator.default)());
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, _chain.default)(this, (0, _createAnyOfValidator.default)(validators, message));
116
+ return (0, _utils.chain)(this, (0, _createAnyOfValidator.default)(validators, message));
122
117
  };
123
118
 
124
119
  var anything = function anything() {
125
- return (0, _nullSafeChain.default)(this, base);
120
+ return this;
126
121
  };
127
122
 
128
123
  var arrayOf = function arrayOf(elementValidator) {
129
- return (0, _nullSafeChain.default)(this, (0, _createArrayOfValidator.default)(elementValidator), {
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, _nullSafeChain.default)(this, _booleanValidator.default);
131
+ return (0, _utils.nullSafeChain)(this, _booleanValidator.default);
137
132
  };
138
133
 
139
134
  var callback = function callback() {
140
- return (0, _nullSafeChain.default)(this, _callbackValidator.default);
135
+ return (0, _utils.nullSafeChain)(this, _callbackValidator.default);
141
136
  };
142
137
 
143
138
  var literal = function literal(literalValue) {
144
- return (0, _nullSafeChain.default)(this, (0, _createLiteralValidator.default)(literalValue));
139
+ return (0, _utils.nullSafeChain)(this, (0, _createLiteralValidator.default)(literalValue));
145
140
  };
146
141
 
147
142
  var number = function number() {
148
- return (0, _nullSafeChain.default)(this, _numberValidator.default, {
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, _nullSafeChain.default)(this, (0, _createMapOfValuesValidator.default)(valuesValidator), {
151
+ return (0, _utils.nullSafeChain)(this, (0, _createMapOfValuesValidator.default)(valuesValidator), {
157
152
  nonEmpty: nonEmptyObject
158
153
  });
159
154
  };
160
155
 
161
- var objectOf = function objectOf(schema) {
162
- var noUnknownFields = function noUnknownFields() {
163
- return (0, _nullSafeChain.default)(this, (0, _createNoUnknownFieldsValidator.default)(schema));
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
- return (0, _nullSafeChain.default)(this, (0, _createObjectOfValidator.default)(schema), {
167
- noUnknownFields: noUnknownFields,
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, _nullSafeChain.default)(this, _stringValidator.default, {
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 _assertValid = require("./assertValid");
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, _assertValid.default)((0, _isInteger.default)(value), value, path, "an integer");
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 _assertValid = require("./assertValid");
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, _assertValid.default)((0, _isNumber.default)(value), value, path, "a number");
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 _assertValid = require("./assertValid");
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, _assertValid.default)((0, _isValidRegExp.default)(value), value, path, "a regular expression");
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 _assertValid = require("./assertValid");
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, _assertValid.default)((0, _isString.default)(value), value, path, "a string");
21
+ (0, _utils.assertValid)((0, _isString.default)(value), value, path, "a string");
22
22
  return value;
23
23
  };
24
24