Socket
Socket
Sign inDemoInstall

simpl-schema

Package Overview
Dependencies
Maintainers
2
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simpl-schema - npm Package Compare versions

Comparing version 1.9.0 to 1.9.1

57

dist/SimpleSchema.js

@@ -44,2 +44,10 @@ "use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }

@@ -184,2 +192,39 @@

/**
* @param {String} key One specific or generic key for which to get the schema.
* @returns {[SimpleSchema, String]} Returns a 2-tuple.
*
* First item: The SimpleSchema instance that actually defines the given key.
*
* For example, if you have several nested objects, each their own SimpleSchema
* instance, and you pass in 'outerObj.innerObj.innerestObj.name' as the key, you'll
* get back the SimpleSchema instance for `outerObj.innerObj.innerestObj` key.
*
* But if you pass in 'outerObj.innerObj.innerestObj.name' as the key and that key is
* defined in the main schema without use of subschemas, then you'll get back the main schema.
*
* Second item: The part of the key that is in the found schema.
*
* Always returns a tuple (array) but the values may be `null`.
*/
}, {
key: "nearestSimpleSchemaInstance",
value: function nearestSimpleSchemaInstance(key) {
if (!key) return [null, null];
var genericKey = _mongoObject.default.makeKeyGeneric(key);
if (this._schema[genericKey]) return [this, genericKey]; // If not defined in this schema, see if it's defined in a subschema
var innerKey;
var nearestSimpleSchemaInstance;
this.forEachAncestorSimpleSchema(key, function (simpleSchema, ancestor, subSchemaKey) {
if (!nearestSimpleSchemaInstance && simpleSchema._schema[subSchemaKey]) {
nearestSimpleSchemaInstance = simpleSchema;
innerKey = subSchemaKey;
}
});
return innerKey ? [nearestSimpleSchemaInstance, innerKey] : [null, null];
}
/**
* @param {String} [key] One specific or generic key for which to get the schema.

@@ -833,5 +878,11 @@ * @returns {Object} The entire schema object or just the definition for one key.

if (typeof label !== 'string' && typeof label !== 'function') return;
if (!Object.prototype.hasOwnProperty.call(_this12._schema, key)) return;
_this12._schema[key].label = label;
_this12._depsLabels[key] && _this12._depsLabels[key].changed();
var _this12$nearestSimple = _this12.nearestSimpleSchemaInstance(key),
_this12$nearestSimple2 = _slicedToArray(_this12$nearestSimple, 2),
schemaInstance = _this12$nearestSimple2[0],
innerKey = _this12$nearestSimple2[1];
if (!schemaInstance) return;
schemaInstance._schema[innerKey].label = label;
schemaInstance._depsLabels[innerKey] && schemaInstance._depsLabels[innerKey].changed();
});

@@ -838,0 +889,0 @@ }

{
"name": "simpl-schema",
"version": "1.9.0",
"version": "1.9.1",
"description": "A schema validation package that supports direct validation of MongoDB update modifier objects.",

@@ -110,4 +110,15 @@ "author": "Eric Dobbertin <aldeed@gmail.com>",

"branches": [
"master"
"main"
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
[
"@semantic-release/github",
{
"successComment": ":tada: This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:\n\nThe release is available on:\n- [npm package (@latest dist-tag)](https://www.npmjs.com/package/simpl-schema/v/${nextRelease.version})\n- [GitHub release](https://github.com/aldeed/simpl-schema/releases/tag/${nextRelease.version})\n\nIf this makes you happy, please consider [becoming a sponsor](https://github.com/sponsors/aldeed).\n\nYour **[semantic-release](https://github.com/semantic-release/semantic-release)** bot :package::rocket:"
}
]
],
"tagFormat": "${version}"

@@ -114,0 +125,0 @@ },

25

README.md
# SimpleSchema (simpl-schema NPM package)
[![Backers on Open Collective](https://opencollective.com/simple-schema-js/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/simple-schema-js/sponsors/badge.svg)](#sponsors) [![Lint, Test, and (Maybe) Publish](https://github.com/aldeed/simpl-schema/workflows/Lint,%20Test,%20and%20(Maybe)%20Publish/badge.svg?event=push)](https://github.com/aldeed/simpl-schema/actions?query=workflow%3A%22Lint%2C+Test%2C+and+%28Maybe%29+Publish%22)
[![Lint, Test, and (Maybe) Publish](https://github.com/aldeed/simpl-schema/workflows/Lint,%20Test,%20and%20(Maybe)%20Publish/badge.svg?event=push)](https://github.com/aldeed/simpl-schema/actions?query=workflow%3A%22Lint%2C+Test%2C+and+%28Maybe%29+Publish%22)

@@ -810,3 +810,3 @@ SimpleSchema validates JavaScript objects to ensure they match a schema. It can also clean the objects to automatically convert types, remove unsupported properties, and add automatic values such that the object is then more likely to pass validation.

- If your autoValue for one field relies on the autoValue or defaultValue of another field, make sure that the other field is listed before the field that relies on it in the schema. autoValues are run in order from least nested, to most nested, so you can assume that parent values will be set, but for fields at the same level, schema order matters. Refer to [issue #204](https://github.com/aldeed/simple-schema-js/issues/204).
- If your autoValue for one field relies on the autoValue or defaultValue of another field, make sure that the other field is listed before the field that relies on it in the schema. autoValues are run in order from least nested, to most nested, so you can assume that parent values will be set, but for fields at the same level, schema order matters. Refer to [issue #204](https://github.com/aldeed/simpl-schema/issues/204).
- An `autoValue` function will always run during cleaning even if that field is not in the object being cleaned. This allows you to provide complex default values. If your function applies only when there is a value, you should add `if (!this.isSet) return;` at the top.

@@ -1142,3 +1142,3 @@

The object syntax is the same as shown [here](https://github.com/aldeed/node-message-box#defining-messages) for `MessageBox.defaults`. When you call `setDefaultMessages`, it simply extends [the default defaults](https://github.com/aldeed/simple-schema-js/blob/master/package/lib/defaultMessages.js#L18). **Be sure to call it before you create any of your SimpleSchema instances**
The object syntax is the same as shown [here](https://github.com/aldeed/node-message-box#defining-messages) for `MessageBox.defaults`. When you call `setDefaultMessages`, it simply extends [the default defaults](https://github.com/aldeed/simpl-schema/blob/main/package/lib/defaultMessages.js#L18). **Be sure to call it before you create any of your SimpleSchema instances**

@@ -1347,23 +1347,6 @@ The `MessageBox` instance for a specific schema instance is `simpleSchemaInstance.messageBox`. You can call `messages` function on this to update the messages for that schema only. Example:

## Backers
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/simple-schema-js#backer)]
<a href="https://opencollective.com/simple-schema-js#backers" target="_blank"><img src="https://opencollective.com/simple-schema-js/backers.svg?width=890"></a>
## Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/simple-schema-js#sponsor)]
You can support this project by [becoming a sponsor](https://github.com/sponsors/aldeed).
<a href="https://opencollective.com/simple-schema-js/sponsor/0/website" target="_blank"><img src="https://opencollective.com/simple-schema-js/sponsor/0/avatar.svg"></a>
<a href="https://opencollective.com/simple-schema-js/sponsor/1/website" target="_blank"><img src="https://opencollective.com/simple-schema-js/sponsor/1/avatar.svg"></a>
<a href="https://opencollective.com/simple-schema-js/sponsor/2/website" target="_blank"><img src="https://opencollective.com/simple-schema-js/sponsor/2/avatar.svg"></a>
<a href="https://opencollective.com/simple-schema-js/sponsor/3/website" target="_blank"><img src="https://opencollective.com/simple-schema-js/sponsor/3/avatar.svg"></a>
<a href="https://opencollective.com/simple-schema-js/sponsor/4/website" target="_blank"><img src="https://opencollective.com/simple-schema-js/sponsor/4/avatar.svg"></a>
<a href="https://opencollective.com/simple-schema-js/sponsor/5/website" target="_blank"><img src="https://opencollective.com/simple-schema-js/sponsor/5/avatar.svg"></a>
<a href="https://opencollective.com/simple-schema-js/sponsor/6/website" target="_blank"><img src="https://opencollective.com/simple-schema-js/sponsor/6/avatar.svg"></a>
<a href="https://opencollective.com/simple-schema-js/sponsor/7/website" target="_blank"><img src="https://opencollective.com/simple-schema-js/sponsor/7/avatar.svg"></a>
<a href="https://opencollective.com/simple-schema-js/sponsor/8/website" target="_blank"><img src="https://opencollective.com/simple-schema-js/sponsor/8/avatar.svg"></a>
<a href="https://opencollective.com/simple-schema-js/sponsor/9/website" target="_blank"><img src="https://opencollective.com/simple-schema-js/sponsor/9/avatar.svg"></a>
## License

@@ -1370,0 +1353,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc