simpl-schema
Advanced tools
Comparing version 1.10.0 to 1.10.1
@@ -52,2 +52,6 @@ "use strict"; | ||
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; } | ||
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; } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
@@ -61,6 +65,2 @@ | ||
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; } | ||
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; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
@@ -560,6 +560,8 @@ | ||
schemaObj = (0, _expandShorthand.default)(schema); | ||
} // Update all of the information cached on the instance | ||
} | ||
var schemaKeys = Object.keys(schemaObj); | ||
var combinedKeys = new Set([].concat(_toConsumableArray(Object.keys(this._schema)), _toConsumableArray(schemaKeys))); // Update all of the information cached on the instance | ||
Object.keys(schemaObj).forEach(function (fieldName) { | ||
schemaKeys.forEach(function (fieldName) { | ||
var definition = standardizeDefinition(schemaObj[fieldName]); // Merge/extend with any existing definition | ||
@@ -583,3 +585,3 @@ | ||
checkAndScrubDefinition(fieldName, _this8._schema[fieldName], _this8._constructorOptions, schemaObj); | ||
checkAndScrubDefinition(fieldName, _this8._schema[fieldName], _this8._constructorOptions, combinedKeys); | ||
}); | ||
@@ -1161,6 +1163,15 @@ checkSchemaOverlap(this._schema); // Set/Reset all of these | ||
return standardizedDef; | ||
} // Checks and mutates definition. Clone it first. | ||
} | ||
/** | ||
* @summary Checks and mutates definition. Clone it first. | ||
* Throws errors if any problems are found. | ||
* @param {String} fieldName Name of field / key | ||
* @param {Object} definition Field definition | ||
* @param {Object} options Options | ||
* @param {Set} allKeys Set of all field names / keys in entire schema | ||
* @return {undefined} Void | ||
*/ | ||
function checkAndScrubDefinition(fieldName, definition, options, fullSchemaObj) { | ||
function checkAndScrubDefinition(fieldName, definition, options, allKeys) { | ||
if (!definition.type) throw new Error("".concat(fieldName, " key is missing \"type\"")); // Validate the field definition | ||
@@ -1193,3 +1204,3 @@ | ||
if (Object.prototype.hasOwnProperty.call(fullSchemaObj, newKey)) { | ||
if (allKeys.has(newKey)) { | ||
throw new Error("The type for \"".concat(fieldName, "\" is set to a SimpleSchema instance that defines \"").concat(newKey, "\", but the parent SimpleSchema instance also tries to define \"").concat(newKey, "\"")); | ||
@@ -1202,3 +1213,3 @@ } | ||
if (couldBeArray && !Object.prototype.hasOwnProperty.call(fullSchemaObj, "".concat(fieldName, ".$"))) { | ||
if (couldBeArray && !allKeys.has("".concat(fieldName, ".$"))) { | ||
throw new Error("\"".concat(fieldName, "\" is Array type but the schema does not include a \"").concat(fieldName, ".$\" definition for the array items\"")); | ||
@@ -1205,0 +1216,0 @@ } // defaultValue -> autoValue |
{ | ||
"name": "simpl-schema", | ||
"version": "1.10.0", | ||
"version": "1.10.1", | ||
"description": "A schema validation package that supports direct validation of MongoDB update modifier objects.", | ||
@@ -5,0 +5,0 @@ "author": "Eric Dobbertin <aldeed@gmail.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
201978
2944