Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mvom

Package Overview
Dependencies
Maintainers
3
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mvom - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

5

CHANGELOG.md
# CHANGELOG.md
## 0.6.1
###### _2020_03_13_
- Allow for regular expression pattern matching for strings and ids. Strings will accept a property named `match` in the schema definition for any string type. Document ids can be matched by providing an `idMatch` property to the Schema constructor options. @reedmattos
- Update some vulnerable dependencies @shawnmcknight
## 0.6.0

@@ -3,0 +8,0 @@ ###### _2020_03_03_

2

index.d.ts

@@ -74,3 +74,3 @@ // TypeScript Version: 2.3

export class Schema {
constructor(definition: GenericObject, opts?: {typeProperty?: string, dictionaries?: GenericObject});
constructor(definition: GenericObject, opts?: {typeProperty?: string, dictionaries?: GenericObject, idMatch?: RegExp});
static Types: {

@@ -77,0 +77,0 @@ ISOCalendarDateTime: typeof ISOCalendarDateTimeType;

@@ -69,2 +69,6 @@ "use strict";

if (this._schema !== null) {
if (this._schema.idMatch != null && !this._schema.idMatch.test(this._id)) {
documentErrors._id = 'Document id does not match pattern';
}
await Promise.all(Object.entries(this._schema.paths).map(async ([keyPath, schemaType]) => {

@@ -71,0 +75,0 @@ let value = (0, _lodash.get)(this, keyPath, null); // cast to complex data type if necessary

@@ -38,2 +38,3 @@ "use strict";

* @param {Object} [options.dictionaries = {}] Additional dictionaries for use in query (key/value paired)
* @param {RegExp} [options.idMatch] Regular expression to validate the record id against
* @example const example = new Schema({ propertyA: [{ property1: { path: '1'} }] })

@@ -55,3 +56,4 @@ * @throws {InvalidParameterError} An invalid parameter was passed to the function

typeProperty = 'type',
dictionaries = {}
dictionaries = {},
idMatch
} = {}) {

@@ -231,2 +233,8 @@ _defineProperty(this, "getMvPaths", () => this._subdocumentSchemas.reduce((mvPaths, schema) => mvPaths.concat(schema.getMvPaths()), this._mvPaths.slice()));

}
if (idMatch != null && !(idMatch instanceof RegExp)) {
throw new _errors.InvalidParameterError({
parameterName: 'idMatch'
});
}
/**

@@ -253,2 +261,10 @@ * Key/value pairs of schema object path structure and associated multivalue dictionary ids

/**
* Regular expression to validate the record id against
* @member {string} idMatch
* @memberof Schema
* @instance
*/
this.idMatch = idMatch;
/**
* The schema definition passed to the constructor

@@ -255,0 +271,0 @@ * @member {Object} _definition

@@ -22,2 +22,3 @@ "use strict";

* @param {string[]} [definition.enum] - Array of allowed values
* @param {RegExp} [definition.match] - Regular expression to validate the property value against
* @throws {InvalidParameterError} An invalid parameter was passed to the function

@@ -35,2 +36,12 @@ */

*/
/**
* Create validation object for match validation
* @function matchValidation
* @memberof StringType
* @static
* @private
* @param {Function|AsyncFunction} defaultValidator - Match validation function to use
* @returns {ValidationObject} Object containing validation function and failure message
*/
constructor(definition) {

@@ -49,2 +60,8 @@ if (definition.path == null) {

if (definition.match != null && !(definition.match instanceof RegExp)) {
throw new _errors.InvalidParameterError({
parameterName: 'definition.match'
});
}
super(definition);

@@ -74,6 +91,20 @@ /**

_defineProperty(this, "_validateMatch", async value => // skip validation on nullish values because a required valdation error, if applicable, is more helpful
value == null || this._match == null || this._match.test(value));
_defineProperty(this, "_validateRequired", async value => value != null && value !== '');
this._enum = definition.enum || null; // add validators for this type
this._enum = definition.enum || null;
/**
* Regular expression to validate the property value against
* @member {RegExp|null} _match
* @memberof StringType
* @instance
* @private
*/
this._match = definition.match || null; // add validators for this type
this._validators.unshift(StringType.matchValidation(this._validateMatch));
this._validators.unshift(StringType.handleEnumValidation(this._validateEnum));

@@ -103,3 +134,11 @@ }

_defineProperty(StringType, "matchValidation", defaultValidator => {
const message = 'Value does not match pattern';
return {
validator: defaultValidator,
message
};
});
var _default = StringType;
exports.default = _default;
{
"name": "mvom",
"author": "STORIS",
"version": "0.6.0",
"version": "0.6.1",
"description": "Multivalue Object Mapper",

@@ -6,0 +6,0 @@ "main": "./js/index.js",

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