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

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.5.6 to 1.5.7

63

dist/clean.js

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = void 0;
exports["default"] = void 0;

@@ -25,6 +25,10 @@ var _clone = _interopRequireDefault(require("clone"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
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; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
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; }

@@ -54,3 +58,4 @@

*/
function clean(ss, doc, options = {}) {
function clean(ss, doc) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
// By default, doc will be filtered and autoconverted

@@ -60,9 +65,9 @@ options = _objectSpread({

isUpsert: false
}, ss._cleanOptions, options); // Clone so we do not mutate
}, ss._cleanOptions, {}, options); // Clone so we do not mutate
const cleanDoc = options.mutate ? doc : (0, _clone.default)(doc);
const mongoObject = options.mongoObject || new _mongoObject.default(cleanDoc, ss.blackboxKeys()); // Clean loop
var cleanDoc = options.mutate ? doc : (0, _clone["default"])(doc);
var mongoObject = options.mongoObject || new _mongoObject["default"](cleanDoc, ss.blackboxKeys()); // Clean loop
if (options.filter || options.autoConvert || options.removeEmptyStrings || options.trimStrings) {
const removedPositions = []; // For removing now-empty objects after
var removedPositions = []; // For removing now-empty objects after

@@ -73,7 +78,7 @@ mongoObject.forEachNode(function eachNode() {

if (this.operator === '$unset') return;
const gKey = this.genericKey;
var gKey = this.genericKey;
if (!gKey) return;
let val = this.value;
var val = this.value;
if (val === undefined) return;
let p; // Filter out props if necessary
var p; // Filter out props if necessary

@@ -91,3 +96,3 @@ if (options.filter && !ss.allowsKey(gKey) || options.removeNullsFromArrays && this.isArrayItem && val === null) {

if (_SimpleSchema.SimpleSchema.debug) {
console.info(`SimpleSchema.clean: filtered out value that would have affected key "${gKey}", which is not allowed by the schema`);
console.info("SimpleSchema.clean: filtered out value that would have affected key \"".concat(gKey, "\", which is not allowed by the schema"));
}

@@ -98,11 +103,11 @@

const outerDef = ss.schema(gKey);
const defs = outerDef && outerDef.type.definitions;
const def = defs && defs[0]; // Autoconvert values if requested and if possible
var outerDef = ss.schema(gKey);
var defs = outerDef && outerDef.type.definitions;
var def = defs && defs[0]; // Autoconvert values if requested and if possible
if (options.autoConvert && def) {
const isValidType = defs.some(definition => {
const errors = _typeValidator.default.call({
var isValidType = defs.some(function (definition) {
var errors = _typeValidator["default"].call({
valueShouldBeChecked: true,
definition,
definition: definition,
value: val

@@ -115,6 +120,6 @@ });

if (!isValidType) {
const newVal = (0, _convertToProperType.default)(val, def.type);
var newVal = (0, _convertToProperType["default"])(val, def.type);
if (newVal !== undefined && newVal !== val) {
_SimpleSchema.SimpleSchema.debug && console.info(`SimpleSchema.clean: autoconverted value ${val} from ${typeof val} to ${typeof newVal} for ${gKey}`);
_SimpleSchema.SimpleSchema.debug && console.info("SimpleSchema.clean: autoconverted value ".concat(val, " from ").concat(_typeof(val), " to ").concat(_typeof(newVal), " for ").concat(gKey));
val = newVal;

@@ -153,9 +158,9 @@ this.updateValue(newVal);

removedPositions.forEach(removedPosition => {
const lastBrace = removedPosition.lastIndexOf('[');
removedPositions.forEach(function (removedPosition) {
var lastBrace = removedPosition.lastIndexOf('[');
if (lastBrace !== -1) {
const removedPositionParent = removedPosition.slice(0, lastBrace);
const value = mongoObject.getValueForPosition(removedPositionParent);
if ((0, _lodash.default)(value)) mongoObject.removeValueForPosition(removedPositionParent);
var removedPositionParent = removedPosition.slice(0, lastBrace);
var value = mongoObject.getValueForPosition(removedPositionParent);
if ((0, _lodash["default"])(value)) mongoObject.removeValueForPosition(removedPositionParent);
}

@@ -167,8 +172,8 @@ });

options.getAutoValues && (0, _setAutoValues.default)(ss.autoValueFunctions(), mongoObject, options.isModifier, options.isUpsert, options.extendAutoValueContext); // Ensure we don't have any operators set to an empty object
options.getAutoValues && (0, _setAutoValues["default"])(ss.autoValueFunctions(), mongoObject, options.isModifier, options.isUpsert, options.extendAutoValueContext); // Ensure we don't have any operators set to an empty object
// since MongoDB 2.6+ will throw errors.
if (options.isModifier) {
Object.keys(cleanDoc || {}).forEach(op => {
if ((0, _lodash.default)(cleanDoc[op])) delete cleanDoc[op];
Object.keys(cleanDoc || {}).forEach(function (op) {
if ((0, _lodash["default"])(cleanDoc[op])) delete cleanDoc[op];
});

@@ -181,4 +186,4 @@ }

var _default = clean;
exports.default = _default;
exports["default"] = _default;
module.exports = exports.default;
module.exports.default = exports.default;

@@ -9,6 +9,6 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
/* eslint-disable func-names, prefer-arrow-callback */
const ss = new _SimpleSchema.SimpleSchema({
var ss = new _SimpleSchema.SimpleSchema({
string: {

@@ -49,3 +49,3 @@ type: String,

},
boolean: {
"boolean": {
type: Boolean,

@@ -103,11 +103,8 @@ optional: true

optional: true,
min() {
min: function min() {
return 10;
},
max() {
max: function max() {
return 20;
}
},

@@ -167,11 +164,8 @@ minMaxNumberExclusive: {

optional: true,
min() {
min: function min() {
return new Date(Date.UTC(2013, 0, 1));
},
max() {
max: function max() {
return new Date(Date.UTC(2013, 11, 31));
}
},

@@ -189,3 +183,3 @@ email: {

customObject: {
type: _Address.default,
type: _Address["default"],
optional: true,

@@ -209,6 +203,6 @@ blackbox: true

ss.clean(given, {
isModifier,
isModifier: isModifier,
mutate: true
});
(0, _expect.default)(given).toEqual(expected);
(0, _expect["default"])(given).toEqual(expected);
};

@@ -241,3 +235,3 @@ }

}, {}, false));
const myObj = new _Address.default('New York', 'NY');
var myObj = new _Address["default"]('New York', 'NY');
it('when you clean a good custom object it is still good', getTest({

@@ -248,3 +242,3 @@ customObject: myObj

}, false));
const myObj2 = {
var myObj2 = {
foo: 'bar',

@@ -258,3 +252,3 @@ 'foobar.foobar': 10000

}, false));
const myObj3 = {
var myObj3 = {
string: 't',

@@ -266,3 +260,3 @@ length: 5

}, false));
const myObj4 = {
var myObj4 = {
string: 't',

@@ -570,3 +564,3 @@ length: null

objectArray: {
boolean: true
"boolean": true
}

@@ -577,3 +571,3 @@ }

objectArray: {
boolean: true
"boolean": true
}

@@ -827,3 +821,3 @@ }

function doTest(isModifier, given, expected) {
const cleanObj = ss.clean(given, {
var cleanObj = ss.clean(given, {
mutate: true,

@@ -835,5 +829,5 @@ filter: false,

getAutoValues: false,
isModifier
isModifier: isModifier
});
(0, _expect.default)(cleanObj).toEqual(expected);
(0, _expect["default"])(cleanObj).toEqual(expected);
} // DOC

@@ -962,3 +956,3 @@

const cleanObj = ss.clean({
var cleanObj = ss.clean({
noTrimString: ' This is a string '

@@ -973,3 +967,3 @@ }, {

});
(0, _expect.default)(cleanObj).toEqual({
(0, _expect["default"])(cleanObj).toEqual({
noTrimString: ' This is a string '

@@ -980,3 +974,3 @@ });

it('does not $unset when the prop is within an object that is already being $set', function () {
const optionalInObject = new _SimpleSchema.SimpleSchema({
var optionalInObject = new _SimpleSchema.SimpleSchema({
requiredObj: {

@@ -993,3 +987,3 @@ type: Object

});
const myObj = {
var myObj = {
$set: {

@@ -1006,3 +1000,3 @@ requiredObj: {

});
(0, _expect.default)(myObj).toEqual({
(0, _expect["default"])(myObj).toEqual({
$set: {

@@ -1016,3 +1010,3 @@ requiredObj: {

it('type convert to array', function () {
const myObj1 = {
var myObj1 = {
allowedStringsArray: 'tuna'

@@ -1023,6 +1017,6 @@ };

});
(0, _expect.default)(myObj1).toEqual({
(0, _expect["default"])(myObj1).toEqual({
allowedStringsArray: ['tuna']
});
const myObj2 = {
var myObj2 = {
$set: {

@@ -1036,3 +1030,3 @@ allowedStringsArray: 'tuna'

});
(0, _expect.default)(myObj2).toEqual({
(0, _expect["default"])(myObj2).toEqual({
$set: {

@@ -1044,3 +1038,3 @@ allowedStringsArray: ['tuna']

it('multi-dimensional arrays', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
geometry: {

@@ -1063,3 +1057,3 @@ type: Object,

});
const doc = {
var doc = {
geometry: {

@@ -1069,11 +1063,11 @@ coordinates: [[[30, 50]]]

};
const expected = JSON.stringify(doc);
(0, _expect.default)(JSON.stringify(schema.clean(doc))).toEqual(expected);
var expected = JSON.stringify(doc);
(0, _expect["default"])(JSON.stringify(schema.clean(doc))).toEqual(expected);
});
it('removeNullsFromArrays removes nulls from arrays', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
names: Array,
'names.$': String
});
const cleanedObject = schema.clean({
var cleanedObject = schema.clean({
names: [null, 'foo', null]

@@ -1083,3 +1077,3 @@ }, {

});
(0, _expect.default)(cleanedObject).toEqual({
(0, _expect["default"])(cleanedObject).toEqual({
names: ['foo']

@@ -1089,3 +1083,3 @@ });

it('removeNullsFromArrays does not remove non-null objects from arrays', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
a: Array,

@@ -1095,3 +1089,3 @@ 'a.$': Object,

});
const cleanedObject = schema.clean({
var cleanedObject = schema.clean({
$set: {

@@ -1106,3 +1100,3 @@ a: [{

(0, _expect.default)(cleanedObject).toEqual({
(0, _expect["default"])(cleanedObject).toEqual({
$set: {

@@ -1116,3 +1110,3 @@ a: [{

it('remove object', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
names: {

@@ -1125,3 +1119,3 @@ type: Array

});
const doc = {
var doc = {
names: [{

@@ -1134,3 +1128,3 @@ hello: 'world'

});
(0, _expect.default)(doc).toEqual({
(0, _expect["default"])(doc).toEqual({
names: []

@@ -1141,13 +1135,13 @@ });

it('should clean sub schemas', function () {
const doubleNestedSchema = new _SimpleSchema.SimpleSchema({
var doubleNestedSchema = new _SimpleSchema.SimpleSchema({
integer: _SimpleSchema.SimpleSchema.Integer
});
const nestedSchema = new _SimpleSchema.SimpleSchema({
var nestedSchema = new _SimpleSchema.SimpleSchema({
doubleNested: doubleNestedSchema
});
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
nested: Array,
'nested.$': nestedSchema
});
const cleanedObject = schema.clean({
var cleanedObject = schema.clean({
nested: [{

@@ -1159,3 +1153,3 @@ doubleNested: {

});
(0, _expect.default)(cleanedObject).toEqual({
(0, _expect["default"])(cleanedObject).toEqual({
nested: [{

@@ -1169,3 +1163,3 @@ doubleNested: {

describe('with SimpleSchema.oneOf(String, Number, Date)', function () {
const oneOfSchema = new _SimpleSchema.SimpleSchema({
var oneOfSchema = new _SimpleSchema.SimpleSchema({
field: {

@@ -1181,6 +1175,6 @@ type: _SimpleSchema.SimpleSchema.oneOf(String, Number, Date)

function doTest(given, expected) {
const cleanObj = oneOfSchema.clean(given, {
var cleanObj = oneOfSchema.clean(given, {
mutate: true
});
(0, _expect.default)(cleanObj).toEqual(expected);
(0, _expect["default"])(cleanObj).toEqual(expected);
}

@@ -1210,3 +1204,3 @@

it('should convert a Date if no Date in oneOf', function () {
const schemaNoDate = new _SimpleSchema.SimpleSchema({
var schemaNoDate = new _SimpleSchema.SimpleSchema({
field: {

@@ -1216,5 +1210,5 @@ type: _SimpleSchema.SimpleSchema.oneOf(String, Number)

});
const date = new Date(12345);
const dateStrng = date.toString();
const cleanObj = schemaNoDate.clean({
var date = new Date(12345);
var dateStrng = date.toString();
var cleanObj = schemaNoDate.clean({
field: date

@@ -1224,3 +1218,3 @@ }, {

});
(0, _expect.default)(cleanObj).toEqual({
(0, _expect["default"])(cleanObj).toEqual({
field: dateStrng

@@ -1230,3 +1224,3 @@ });

it('should convert a String if no String in oneOf', function () {
const schemaNoDate = new _SimpleSchema.SimpleSchema({
var schemaNoDate = new _SimpleSchema.SimpleSchema({
field: {

@@ -1236,3 +1230,3 @@ type: _SimpleSchema.SimpleSchema.oneOf(Number, Date)

});
const cleanObj = schemaNoDate.clean({
var cleanObj = schemaNoDate.clean({
field: '12345'

@@ -1242,3 +1236,3 @@ }, {

});
(0, _expect.default)(cleanObj).toEqual({
(0, _expect["default"])(cleanObj).toEqual({
field: 12345

@@ -1248,3 +1242,3 @@ });

it('should convert a Number if no Number in oneOf', function () {
const schemaNoDate = new _SimpleSchema.SimpleSchema({
var schemaNoDate = new _SimpleSchema.SimpleSchema({
field: {

@@ -1254,3 +1248,3 @@ type: _SimpleSchema.SimpleSchema.oneOf(String, Date)

});
const cleanObj = schemaNoDate.clean({
var cleanObj = schemaNoDate.clean({
field: 12345

@@ -1260,3 +1254,3 @@ }, {

});
(0, _expect.default)(cleanObj).toEqual({
(0, _expect["default"])(cleanObj).toEqual({
field: '12345'

@@ -1357,3 +1351,3 @@ });

it('should convert a Date if no Date in oneOf', function () {
const schemaNoDate = new _SimpleSchema.SimpleSchema({
var schemaNoDate = new _SimpleSchema.SimpleSchema({
field: {

@@ -1363,5 +1357,5 @@ type: _SimpleSchema.SimpleSchema.oneOf(String, Number)

});
const date = new Date(12345);
const dateString = date.toString();
const cleanObj = schemaNoDate.clean({
var date = new Date(12345);
var dateString = date.toString();
var cleanObj = schemaNoDate.clean({
$set: {

@@ -1373,3 +1367,3 @@ field: date

});
(0, _expect.default)(cleanObj).toEqual({
(0, _expect["default"])(cleanObj).toEqual({
$set: {

@@ -1381,3 +1375,3 @@ field: dateString

it('should convert a String if no String in oneOf', function () {
const schemaNoDate = new _SimpleSchema.SimpleSchema({
var schemaNoDate = new _SimpleSchema.SimpleSchema({
field: {

@@ -1387,3 +1381,3 @@ type: _SimpleSchema.SimpleSchema.oneOf(Number, Date)

});
const cleanObj = schemaNoDate.clean({
var cleanObj = schemaNoDate.clean({
$set: {

@@ -1395,3 +1389,3 @@ field: '12345'

});
(0, _expect.default)(cleanObj).toEqual({
(0, _expect["default"])(cleanObj).toEqual({
$set: {

@@ -1403,3 +1397,3 @@ field: 12345

it('should convert a Number if no Number in oneOf', function () {
const schemaNoDate = new _SimpleSchema.SimpleSchema({
var schemaNoDate = new _SimpleSchema.SimpleSchema({
field: {

@@ -1409,3 +1403,3 @@ type: _SimpleSchema.SimpleSchema.oneOf(String, Date)

});
const cleanObj = schemaNoDate.clean({
var cleanObj = schemaNoDate.clean({
$set: {

@@ -1417,3 +1411,3 @@ field: 12345

});
(0, _expect.default)(cleanObj).toEqual({
(0, _expect["default"])(cleanObj).toEqual({
$set: {

@@ -1420,0 +1414,0 @@ field: '12345'

@@ -7,3 +7,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -14,3 +14,3 @@ /* eslint-disable func-names, prefer-arrow-callback */

it('empty', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -23,11 +23,10 @@ type: String,

optional: true,
autoValue() {
(0, _expect.default)(this.key).toBe('bar');
(0, _expect.default)(this.closestSubschemaFieldName).toBe(null);
(0, _expect.default)(this.isSet).toBe(false);
(0, _expect.default)(this.value).toBe(undefined);
(0, _expect.default)(this.operator).toBe(null);
const foo = this.field('foo');
(0, _expect.default)(foo).toEqual({
autoValue: function autoValue() {
(0, _expect["default"])(this.key).toBe('bar');
(0, _expect["default"])(this.closestSubschemaFieldName).toBe(null);
(0, _expect["default"])(this.isSet).toBe(false);
(0, _expect["default"])(this.value).toBe(undefined);
(0, _expect["default"])(this.operator).toBe(null);
var foo = this.field('foo');
(0, _expect["default"])(foo).toEqual({
isSet: false,

@@ -37,4 +36,4 @@ operator: null,

});
const fooSibling = this.siblingField('foo');
(0, _expect.default)(fooSibling).toEqual({
var fooSibling = this.siblingField('foo');
(0, _expect["default"])(fooSibling).toEqual({
isSet: false,

@@ -44,4 +43,4 @@ operator: null,

});
const fooParent = this.parentField();
(0, _expect.default)(fooParent).toEqual({
var fooParent = this.parentField();
(0, _expect["default"])(fooParent).toEqual({
isSet: false,

@@ -52,3 +51,2 @@ operator: null,

}
}

@@ -59,3 +57,3 @@ });

it('normal other key', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -68,9 +66,8 @@ type: String,

optional: true,
autoValue() {
(0, _expect.default)(this.isSet).toBe(false);
(0, _expect.default)(this.value).toBe(undefined);
(0, _expect.default)(this.operator).toBe(null);
const foo = this.field('foo');
(0, _expect.default)(foo).toEqual({
autoValue: function autoValue() {
(0, _expect["default"])(this.isSet).toBe(false);
(0, _expect["default"])(this.value).toBe(undefined);
(0, _expect["default"])(this.operator).toBe(null);
var foo = this.field('foo');
(0, _expect["default"])(foo).toEqual({
isSet: true,

@@ -80,4 +77,4 @@ operator: null,

});
const fooSibling = this.siblingField('foo');
(0, _expect.default)(fooSibling).toEqual({
var fooSibling = this.siblingField('foo');
(0, _expect["default"])(fooSibling).toEqual({
isSet: true,

@@ -87,4 +84,4 @@ operator: null,

});
const fooParent = this.parentField();
(0, _expect.default)(fooParent).toEqual({
var fooParent = this.parentField();
(0, _expect["default"])(fooParent).toEqual({
isSet: false,

@@ -95,3 +92,2 @@ operator: null,

}
}

@@ -104,3 +100,3 @@ });

it('normal self and other key', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -113,9 +109,8 @@ type: String,

optional: true,
autoValue() {
(0, _expect.default)(this.isSet).toBe(true);
(0, _expect.default)(this.value).toBe(true);
(0, _expect.default)(this.operator).toBe(null);
const foo = this.field('foo');
(0, _expect.default)(foo).toEqual({
autoValue: function autoValue() {
(0, _expect["default"])(this.isSet).toBe(true);
(0, _expect["default"])(this.value).toBe(true);
(0, _expect["default"])(this.operator).toBe(null);
var foo = this.field('foo');
(0, _expect["default"])(foo).toEqual({
isSet: true,

@@ -125,4 +120,4 @@ operator: null,

});
const fooSibling = this.siblingField('foo');
(0, _expect.default)(fooSibling).toEqual({
var fooSibling = this.siblingField('foo');
(0, _expect["default"])(fooSibling).toEqual({
isSet: true,

@@ -132,4 +127,4 @@ operator: null,

});
const fooParent = this.parentField();
(0, _expect.default)(fooParent).toEqual({
var fooParent = this.parentField();
(0, _expect["default"])(fooParent).toEqual({
isSet: false,

@@ -140,3 +135,2 @@ operator: null,

}
}

@@ -150,3 +144,3 @@ });

it('parentField', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -159,5 +153,4 @@ type: Object,

optional: true,
autoValue() {
(0, _expect.default)(this.parentField()).toEqual({
autoValue: function autoValue() {
(0, _expect["default"])(this.parentField()).toEqual({
isSet: true,

@@ -168,3 +161,2 @@ operator: null,

}
}

@@ -177,15 +169,13 @@ });

it('closestSubschemaFieldName set', function () {
const schema1 = new _SimpleSchema.SimpleSchema({
var schema1 = new _SimpleSchema.SimpleSchema({
dug: {
type: Boolean,
optional: true,
autoValue() {
(0, _expect.default)(this.key).toBe('dig.dug');
(0, _expect.default)(this.closestSubschemaFieldName).toBe('dig');
autoValue: function autoValue() {
(0, _expect["default"])(this.key).toBe('dig.dug');
(0, _expect["default"])(this.closestSubschemaFieldName).toBe('dig');
}
}
});
const schema2 = new _SimpleSchema.SimpleSchema({
var schema2 = new _SimpleSchema.SimpleSchema({
dig: {

@@ -201,3 +191,3 @@ type: schema1,

it('normal self and no other key with unset', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -210,9 +200,8 @@ type: String,

optional: true,
autoValue() {
(0, _expect.default)(this.isSet).toBe(true);
(0, _expect.default)(this.value).toBe(false);
(0, _expect.default)(this.operator).toBe(null);
const foo = this.field('foo');
(0, _expect.default)(foo).toEqual({
autoValue: function autoValue() {
(0, _expect["default"])(this.isSet).toBe(true);
(0, _expect["default"])(this.value).toBe(false);
(0, _expect["default"])(this.operator).toBe(null);
var foo = this.field('foo');
(0, _expect["default"])(foo).toEqual({
isSet: false,

@@ -222,4 +211,4 @@ operator: null,

});
const fooSibling = this.siblingField('foo');
(0, _expect.default)(fooSibling).toEqual({
var fooSibling = this.siblingField('foo');
(0, _expect["default"])(fooSibling).toEqual({
isSet: false,

@@ -229,4 +218,4 @@ operator: null,

});
const fooParent = this.parentField();
(0, _expect.default)(fooParent).toEqual({
var fooParent = this.parentField();
(0, _expect["default"])(fooParent).toEqual({
isSet: false,

@@ -238,12 +227,11 @@ operator: null,

}
}
});
const doc = {
var doc = {
bar: false
};
(0, _expect.default)(schema.clean(doc)).toEqual({});
(0, _expect["default"])(schema.clean(doc)).toEqual({});
});
it('$set self and no other key', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -256,9 +244,8 @@ type: String,

optional: true,
autoValue() {
(0, _expect.default)(this.isSet).toBe(true);
(0, _expect.default)(this.value).toBe(false);
(0, _expect.default)(this.operator).toBe('$set');
const foo = this.field('foo');
(0, _expect.default)(foo).toEqual({
autoValue: function autoValue() {
(0, _expect["default"])(this.isSet).toBe(true);
(0, _expect["default"])(this.value).toBe(false);
(0, _expect["default"])(this.operator).toBe('$set');
var foo = this.field('foo');
(0, _expect["default"])(foo).toEqual({
isSet: false,

@@ -268,4 +255,4 @@ operator: null,

});
const fooSibling = this.siblingField('foo');
(0, _expect.default)(fooSibling).toEqual({
var fooSibling = this.siblingField('foo');
(0, _expect["default"])(fooSibling).toEqual({
isSet: false,

@@ -275,4 +262,4 @@ operator: null,

});
const fooParent = this.parentField();
(0, _expect.default)(fooParent).toEqual({
var fooParent = this.parentField();
(0, _expect["default"])(fooParent).toEqual({
isSet: false,

@@ -283,6 +270,5 @@ operator: null,

}
}
});
const doc = {
var doc = {
$set: {

@@ -293,3 +279,3 @@ bar: false

schema.clean(doc);
(0, _expect.default)(doc).toEqual({
(0, _expect["default"])(doc).toEqual({
$set: {

@@ -301,3 +287,3 @@ bar: false

it('$set self and another key and change self', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -310,9 +296,8 @@ type: String,

optional: true,
autoValue() {
(0, _expect.default)(this.isSet).toBe(true);
(0, _expect.default)(this.value).toBe(false);
(0, _expect.default)(this.operator).toBe('$set');
const foo = this.field('foo');
(0, _expect.default)(foo).toEqual({
autoValue: function autoValue() {
(0, _expect["default"])(this.isSet).toBe(true);
(0, _expect["default"])(this.value).toBe(false);
(0, _expect["default"])(this.operator).toBe('$set');
var foo = this.field('foo');
(0, _expect["default"])(foo).toEqual({
isSet: true,

@@ -322,4 +307,4 @@ operator: '$set',

});
const fooSibling = this.siblingField('foo');
(0, _expect.default)(fooSibling).toEqual({
var fooSibling = this.siblingField('foo');
(0, _expect["default"])(fooSibling).toEqual({
isSet: true,

@@ -329,4 +314,4 @@ operator: '$set',

});
const fooParent = this.parentField();
(0, _expect.default)(fooParent).toEqual({
var fooParent = this.parentField();
(0, _expect["default"])(fooParent).toEqual({
isSet: false,

@@ -338,6 +323,5 @@ operator: null,

}
}
});
const doc = {
var doc = {
$set: {

@@ -348,3 +332,3 @@ foo: 'clown',

};
(0, _expect.default)(schema.clean(doc)).toEqual({
(0, _expect["default"])(schema.clean(doc)).toEqual({
$set: {

@@ -357,3 +341,3 @@ foo: 'clown',

it('adds $set when missing', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -366,9 +350,8 @@ type: String,

optional: true,
autoValue() {
(0, _expect.default)(this.isSet).toBe(false);
(0, _expect.default)(this.value).toBe(undefined);
(0, _expect.default)(this.operator).toBe('$set');
const foo = this.field('foo');
(0, _expect.default)(foo).toEqual({
autoValue: function autoValue() {
(0, _expect["default"])(this.isSet).toBe(false);
(0, _expect["default"])(this.value).toBe(undefined);
(0, _expect["default"])(this.operator).toBe('$set');
var foo = this.field('foo');
(0, _expect["default"])(foo).toEqual({
isSet: false,

@@ -378,4 +361,4 @@ operator: null,

});
const fooSibling = this.siblingField('foo');
(0, _expect.default)(fooSibling).toEqual({
var fooSibling = this.siblingField('foo');
(0, _expect["default"])(fooSibling).toEqual({
isSet: false,

@@ -385,4 +368,4 @@ operator: null,

});
const fooParent = this.parentField();
(0, _expect.default)(fooParent).toEqual({
var fooParent = this.parentField();
(0, _expect["default"])(fooParent).toEqual({
isSet: false,

@@ -396,6 +379,5 @@ operator: null,

}
}
});
(0, _expect.default)(schema.clean({}, {
(0, _expect["default"])(schema.clean({}, {
isModifier: true

@@ -410,3 +392,3 @@ })).toEqual({

it('content autoValues', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
content: {

@@ -419,6 +401,5 @@ type: String,

optional: true,
autoValue: function autoValue() {
var content = this.field('content');
autoValue() {
const content = this.field('content');
if (content.isSet) {

@@ -440,3 +421,2 @@ if (!this.operator) {

}
},

@@ -452,6 +432,6 @@ 'updatesHistory.$': {

let result = schema.clean({
var result = schema.clean({
content: 'foo'
});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
content: 'foo',

@@ -469,3 +449,3 @@ updatesHistory: [{

});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
$set: {

@@ -483,3 +463,3 @@ content: 'foo'

it('array of objects autoValues', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
avArrayOfObjects: {

@@ -497,10 +477,8 @@ type: Array,

type: String,
autoValue() {
autoValue: function autoValue() {
return 'bar';
}
}
});
let result = schema.clean({
var result = schema.clean({
$push: {

@@ -512,3 +490,3 @@ avArrayOfObjects: {

});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
$push: {

@@ -530,3 +508,3 @@ avArrayOfObjects: {

});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
$set: {

@@ -544,8 +522,7 @@ avArrayOfObjects: [{

it('$each in autoValue pseudo modifier', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
psuedoEach: {
type: Array,
optional: true,
autoValue() {
autoValue: function autoValue() {
if (this.isSet && this.operator === '$set') {

@@ -559,3 +536,2 @@ return {

}
},

@@ -566,3 +542,3 @@ 'psuedoEach.$': {

});
const result = schema.clean({
var result = schema.clean({
$set: {

@@ -572,3 +548,3 @@ psuedoEach: ['foo', 'bar']

});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
$push: {

@@ -582,3 +558,3 @@ psuedoEach: {

it('simple autoValues', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
name: {

@@ -589,12 +565,9 @@ type: String

type: _SimpleSchema.SimpleSchema.Integer,
autoValue() {
autoValue: function autoValue() {
if (!this.isSet) return 5;
}
},
updateCount: {
type: _SimpleSchema.SimpleSchema.Integer,
autoValue() {
autoValue: function autoValue() {
if (!this.operator) return 0;

@@ -605,3 +578,2 @@ return {

}
},

@@ -611,16 +583,14 @@ firstWord: {

optional: true,
autoValue() {
const content = this.field('content');
autoValue: function autoValue() {
var content = this.field('content');
if (content.isSet) return content.value.split(' ')[0];
this.unset();
}
}
});
let result = schema.clean({
var result = schema.clean({
name: 'Test',
firstWord: 'Illegal to manually set value'
});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
name: 'Test',

@@ -634,3 +604,3 @@ someDefault: 5,

});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
name: 'Test',

@@ -646,3 +616,3 @@ someDefault: 20,

});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
$set: {

@@ -658,16 +628,14 @@ name: 'Test',

it('objects in arrays', function () {
const subSchema = new _SimpleSchema.SimpleSchema({
var subSchema = new _SimpleSchema.SimpleSchema({
value: {
type: String,
autoValue() {
(0, _expect.default)(this.isSet).toBe(true);
(0, _expect.default)(this.operator).toEqual('$set');
(0, _expect.default)(this.value).toEqual('should be overridden by autovalue');
autoValue: function autoValue() {
(0, _expect["default"])(this.isSet).toBe(true);
(0, _expect["default"])(this.operator).toEqual('$set');
(0, _expect["default"])(this.value).toEqual('should be overridden by autovalue');
return 'autovalue';
}
}
});
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
children: {

@@ -680,3 +648,3 @@ type: Array

});
const result = schema.clean({
var result = schema.clean({
$set: {

@@ -688,15 +656,13 @@ 'children.$.value': 'should be overridden by autovalue'

});
(0, _expect.default)(result.$set['children.$.value']).toBe('autovalue');
(0, _expect["default"])(result.$set['children.$.value']).toBe('autovalue');
});
it('operator correct for $pull', function () {
let called = false;
const schema = new _SimpleSchema.SimpleSchema({
var called = false;
var schema = new _SimpleSchema.SimpleSchema({
foo: {
type: Array,
autoValue() {
autoValue: function autoValue() {
called = true;
(0, _expect.default)(this.operator).toEqual('$pull');
(0, _expect["default"])(this.operator).toEqual('$pull');
}
},

@@ -712,7 +678,7 @@ 'foo.$': {

});
(0, _expect.default)(called).toBe(true);
(0, _expect["default"])(called).toBe(true);
});
it('issue 340', function () {
let called = 0;
const schema = new _SimpleSchema.SimpleSchema({
var called = 0;
var schema = new _SimpleSchema.SimpleSchema({
field1: {

@@ -723,10 +689,8 @@ type: _SimpleSchema.SimpleSchema.Integer

type: String,
autoValue() {
autoValue: function autoValue() {
called++;
(0, _expect.default)(this.field('field1').value).toBe(1);
(0, _expect.default)(this.siblingField('field1').value).toBe(1);
(0, _expect["default"])(this.field('field1').value).toBe(1);
(0, _expect["default"])(this.siblingField('field1').value).toBe(1);
return 'foo';
}
}

@@ -742,6 +706,6 @@ });

});
(0, _expect.default)(called).toBe(2);
(0, _expect["default"])(called).toBe(2);
});
it('clean options should be merged when extending', function () {
const schema1 = new _SimpleSchema.SimpleSchema({
var schema1 = new _SimpleSchema.SimpleSchema({
a: String

@@ -754,5 +718,5 @@ }, {

});
const schema2 = new _SimpleSchema.SimpleSchema({});
var schema2 = new _SimpleSchema.SimpleSchema({});
schema2.extend(schema1);
(0, _expect.default)(schema2.clean({
(0, _expect["default"])(schema2.clean({
a: 1

@@ -764,3 +728,3 @@ })).toEqual({

it('array items', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
tags: {

@@ -772,19 +736,17 @@ type: Array,

type: String,
autoValue() {
autoValue: function autoValue() {
if (this.isSet) return this.value.toLowerCase();
}
}
});
const obj = {
var obj = {
tags: []
};
(0, _expect.default)(schema.clean(obj)).toEqual({
(0, _expect["default"])(schema.clean(obj)).toEqual({
tags: []
});
const obj2 = {
var obj2 = {
tags: ['FOO', 'BAR']
};
(0, _expect.default)(schema.clean(obj2)).toEqual({
(0, _expect["default"])(schema.clean(obj2)).toEqual({
tags: ['foo', 'bar']

@@ -794,3 +756,3 @@ });

it('updates existing objects when deeply nested (plain)', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
nested: Array,

@@ -801,4 +763,3 @@ 'nested.$': Object,

type: _SimpleSchema.SimpleSchema.Integer,
autoValue() {
autoValue: function autoValue() {
if (!this.value) {

@@ -808,6 +769,5 @@ return 5;

}
}
});
const cleanedObject = schema.clean({
var cleanedObject = schema.clean({
nested: [{

@@ -821,3 +781,3 @@ doubleNested: {}

});
(0, _expect.default)(cleanedObject).toEqual({
(0, _expect["default"])(cleanedObject).toEqual({
nested: [{

@@ -835,3 +795,3 @@ doubleNested: {

it('updates existing objects when deeply nested (modifier)', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
nested: Array,

@@ -842,4 +802,3 @@ 'nested.$': Object,

type: _SimpleSchema.SimpleSchema.Integer,
autoValue() {
autoValue: function autoValue() {
if (!this.value) {

@@ -849,6 +808,5 @@ return 5;

}
}
});
const cleanedObject = schema.clean({
var cleanedObject = schema.clean({
$push: {

@@ -860,3 +818,3 @@ nested: {

});
(0, _expect.default)(cleanedObject).toEqual({
(0, _expect["default"])(cleanedObject).toEqual({
$push: {

@@ -872,3 +830,3 @@ nested: {

it('updates deeply nested with empty $set', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
nested: Array,

@@ -878,4 +836,3 @@ 'nested.$': Object,

type: Object,
autoValue() {
autoValue: function autoValue() {
if (!this.value) {

@@ -885,8 +842,6 @@ return {};

}
},
'nested.$.doubleNested.integer': {
type: _SimpleSchema.SimpleSchema.Integer,
autoValue() {
autoValue: function autoValue() {
if (!this.value) {

@@ -896,6 +851,5 @@ return 5;

}
}
});
const cleanedObject = schema.clean({
var cleanedObject = schema.clean({
$set: {

@@ -905,3 +859,3 @@ nested: [{}]

});
(0, _expect.default)(cleanedObject).toEqual({
(0, _expect["default"])(cleanedObject).toEqual({
$set: {

@@ -917,3 +871,3 @@ nested: [{

it('updates deeply nested with $set having dotted array key', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
nested: Array,

@@ -924,4 +878,3 @@ 'nested.$': Object,

type: _SimpleSchema.SimpleSchema.Integer,
autoValue() {
autoValue: function autoValue() {
if (!this.value) {

@@ -931,6 +884,5 @@ return 5;

}
}
});
const cleanedObject = schema.clean({
var cleanedObject = schema.clean({
$set: {

@@ -940,3 +892,3 @@ 'nested.0.doubleNested': {}

});
(0, _expect.default)(cleanedObject).toEqual({
(0, _expect["default"])(cleanedObject).toEqual({
$set: {

@@ -950,7 +902,6 @@ 'nested.0.doubleNested': {

it('should add auto values to sub schemas for plain objects', function () {
const doubleNestedSchema = new _SimpleSchema.SimpleSchema({
var doubleNestedSchema = new _SimpleSchema.SimpleSchema({
integer: {
type: _SimpleSchema.SimpleSchema.Integer,
autoValue() {
autoValue: function autoValue() {
if (!this.value) {

@@ -960,13 +911,12 @@ return 5;

}
}
});
const nestedSchema = new _SimpleSchema.SimpleSchema({
var nestedSchema = new _SimpleSchema.SimpleSchema({
doubleNested: doubleNestedSchema
});
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
nested: Array,
'nested.$': nestedSchema
});
const cleanedObject = schema.clean({
var cleanedObject = schema.clean({
nested: [{

@@ -980,3 +930,3 @@ doubleNested: {}

});
(0, _expect.default)(cleanedObject).toEqual({
(0, _expect["default"])(cleanedObject).toEqual({
nested: [{

@@ -994,7 +944,6 @@ doubleNested: {

it('should add auto values to sub schemas for modifiers objects', function () {
const doubleNestedSchema = new _SimpleSchema.SimpleSchema({
var doubleNestedSchema = new _SimpleSchema.SimpleSchema({
integer: {
type: _SimpleSchema.SimpleSchema.Integer,
autoValue() {
autoValue: function autoValue() {
if (!this.value) {

@@ -1004,13 +953,12 @@ return 5;

}
}
});
const nestedSchema = new _SimpleSchema.SimpleSchema({
var nestedSchema = new _SimpleSchema.SimpleSchema({
doubleNested: doubleNestedSchema
});
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
nested: Array,
'nested.$': nestedSchema
});
const cleanedObject = schema.clean({
var cleanedObject = schema.clean({
$push: {

@@ -1022,3 +970,3 @@ nested: {

});
(0, _expect.default)(cleanedObject).toEqual({
(0, _expect["default"])(cleanedObject).toEqual({
$push: {

@@ -1034,3 +982,3 @@ nested: {

it('after cleaning with one extended, autoValues do not bleed over', function () {
const schema1 = new _SimpleSchema.SimpleSchema({
var schema1 = new _SimpleSchema.SimpleSchema({
n: Number,

@@ -1042,3 +990,3 @@ obj: {

});
const schema2 = schema1.clone().extend({
var schema2 = schema1.clone().extend({
'obj.b': {

@@ -1056,6 +1004,6 @@ type: _SimpleSchema.SimpleSchema.Integer,

(0, _expect.default)(schema1.clean({})).toEqual({
(0, _expect["default"])(schema1.clean({})).toEqual({
obj: {}
});
(0, _expect.default)(schema2.clean({})).toEqual({
(0, _expect["default"])(schema2.clean({})).toEqual({
obj: {

@@ -1065,6 +1013,6 @@ b: 1

});
(0, _expect.default)(schema1.clean({})).toEqual({
(0, _expect["default"])(schema1.clean({})).toEqual({
obj: {}
});
(0, _expect.default)(schema2.clean({})).toEqual({
(0, _expect["default"])(schema2.clean({})).toEqual({
obj: {

@@ -1071,0 +1019,0 @@ b: 1

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = void 0;
exports["default"] = void 0;

@@ -15,10 +15,20 @@ var _clone = _interopRequireDefault(require("clone"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
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; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
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; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function getFieldInfo(mongoObject, key) {
const keyInfo = mongoObject.getInfoForKey(key) || {};
var keyInfo = mongoObject.getInfoForKey(key) || {};
return {

@@ -31,4 +41,8 @@ isSet: keyInfo.value !== undefined,

class AutoValueRunner {
constructor(options) {
var AutoValueRunner =
/*#__PURE__*/
function () {
function AutoValueRunner(options) {
_classCallCheck(this, AutoValueRunner);
this.options = options;

@@ -38,100 +52,98 @@ this.doneKeys = [];

runForPosition({
key: affectedKey,
operator,
position,
value
}) {
const {
closestSubschemaFieldName,
extendedAutoValueContext,
func,
isModifier,
isUpsert,
mongoObject
} = this.options; // If already called for this key, skip it
_createClass(AutoValueRunner, [{
key: "runForPosition",
value: function runForPosition(_ref) {
var affectedKey = _ref.key,
operator = _ref.operator,
position = _ref.position,
value = _ref.value;
var _this$options = this.options,
closestSubschemaFieldName = _this$options.closestSubschemaFieldName,
extendedAutoValueContext = _this$options.extendedAutoValueContext,
func = _this$options.func,
isModifier = _this$options.isModifier,
isUpsert = _this$options.isUpsert,
mongoObject = _this$options.mongoObject; // If already called for this key, skip it
if ((0, _lodash.default)(this.doneKeys, affectedKey)) return;
const fieldParentName = (0, _utility.getParentOfKey)(affectedKey, true);
const parentFieldInfo = getFieldInfo(mongoObject, fieldParentName.slice(0, -1));
let doUnset = false;
if ((0, _lodash["default"])(this.doneKeys, affectedKey)) return;
var fieldParentName = (0, _utility.getParentOfKey)(affectedKey, true);
var parentFieldInfo = getFieldInfo(mongoObject, fieldParentName.slice(0, -1));
var doUnset = false;
if (Array.isArray(parentFieldInfo.value)) {
if (isNaN(affectedKey.split('.').slice(-1).pop())) {
// parent is an array, but the key to be set is not an integer (see issue #80)
return;
if (Array.isArray(parentFieldInfo.value)) {
if (isNaN(affectedKey.split('.').slice(-1).pop())) {
// parent is an array, but the key to be set is not an integer (see issue #80)
return;
}
}
}
const autoValue = func.call(_objectSpread({
closestSubschemaFieldName: closestSubschemaFieldName.length ? closestSubschemaFieldName : null,
var autoValue = func.call(_objectSpread({
closestSubschemaFieldName: closestSubschemaFieldName.length ? closestSubschemaFieldName : null,
field: function field(fName) {
return getFieldInfo(mongoObject, closestSubschemaFieldName + fName);
},
isModifier: isModifier,
isUpsert: isUpsert,
isSet: value !== undefined,
key: affectedKey,
operator: operator,
parentField: function parentField() {
return parentFieldInfo;
},
siblingField: function siblingField(fName) {
return getFieldInfo(mongoObject, fieldParentName + fName);
},
unset: function unset() {
doUnset = true;
},
value: value
}, extendedAutoValueContext || {}), mongoObject.getObject()); // Update tracking of which keys we've run autovalue for
field(fName) {
return getFieldInfo(mongoObject, closestSubschemaFieldName + fName);
},
this.doneKeys.push(affectedKey);
if (doUnset && position) mongoObject.removeValueForPosition(position);
if (autoValue === undefined) return; // If the user's auto value is of the pseudo-modifier format, parse it
// into operator and value.
isModifier,
isUpsert,
isSet: value !== undefined,
key: affectedKey,
operator,
if (isModifier) {
var op;
var newValue;
parentField() {
return parentFieldInfo;
},
if (autoValue && _typeof(autoValue) === 'object') {
var avOperator = Object.keys(autoValue).find(function (avProp) {
return avProp.substring(0, 1) === '$';
});
siblingField(fName) {
return getFieldInfo(mongoObject, fieldParentName + fName);
},
if (avOperator) {
op = avOperator;
newValue = autoValue[avOperator];
}
} // Add $set for updates and upserts if necessary. Keep this
// above the "if (op)" block below since we might change op
// in this line.
unset() {
doUnset = true;
},
value
}, extendedAutoValueContext || {}), mongoObject.getObject()); // Update tracking of which keys we've run autovalue for
if (!op && position.slice(0, 1) !== '$') {
op = '$set';
newValue = autoValue;
}
this.doneKeys.push(affectedKey);
if (doUnset && position) mongoObject.removeValueForPosition(position);
if (autoValue === undefined) return; // If the user's auto value is of the pseudo-modifier format, parse it
// into operator and value.
if (isModifier) {
let op;
let newValue;
if (autoValue && typeof autoValue === 'object') {
const avOperator = Object.keys(autoValue).find(avProp => avProp.substring(0, 1) === '$');
if (avOperator) {
op = avOperator;
newValue = autoValue[avOperator];
if (op) {
// Update/change value
mongoObject.removeValueForPosition(position);
mongoObject.setValueForPosition("".concat(op, "[").concat(affectedKey, "]"), (0, _clone["default"])(newValue));
return;
}
} // Add $set for updates and upserts if necessary. Keep this
// above the "if (op)" block below since we might change op
// in this line.
} // Update/change value. Cloning is necessary in case it's an object, because
// if we later set some keys within it, they'd be set on the original object, too.
if (!op && position.slice(0, 1) !== '$') {
op = '$set';
newValue = autoValue;
}
mongoObject.setValueForPosition(position, (0, _clone["default"])(autoValue));
}
}]);
if (op) {
// Update/change value
mongoObject.removeValueForPosition(position);
mongoObject.setValueForPosition(`${op}[${affectedKey}]`, (0, _clone.default)(newValue));
return;
}
} // Update/change value. Cloning is necessary in case it's an object, because
// if we later set some keys within it, they'd be set on the original object, too.
return AutoValueRunner;
}();
mongoObject.setValueForPosition(position, (0, _clone.default)(autoValue));
}
}
exports.default = AutoValueRunner;
exports["default"] = AutoValueRunner;
module.exports = exports.default;
module.exports.default = exports.default;

@@ -6,6 +6,8 @@ "use strict";

});
exports.default = void 0;
exports["default"] = void 0;
var _SimpleSchema = require("../SimpleSchema");
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
/**

@@ -20,3 +22,3 @@ * Converts value to proper type

// Can't and shouldn't convert arrays or objects or null
if (Array.isArray(value) || value && (typeof value === 'function' || typeof value === 'object') && !(value instanceof Date) || value === null) return value; // Convert to String type
if (Array.isArray(value) || value && (typeof value === 'function' || _typeof(value) === 'object') && !(value instanceof Date) || value === null) return value; // Convert to String type

@@ -32,3 +34,3 @@ if (type === String) {

// Try to convert numeric strings to numbers
const numberVal = Number(value);
var numberVal = Number(value);
if (!isNaN(numberVal)) return numberVal;

@@ -47,3 +49,3 @@ } // Leave it; will fail validation

if (typeof value === 'string') {
const parsedDate = Date.parse(value);
var parsedDate = Date.parse(value);
if (isNaN(parsedDate) === false) return new Date(parsedDate);

@@ -73,4 +75,4 @@ }

var _default = convertToProperType;
exports.default = _default;
exports["default"] = _default;
module.exports = exports.default;
module.exports.default = exports.default;

@@ -7,3 +7,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -13,25 +13,25 @@ /* eslint-disable func-names, prefer-arrow-callback */

it('convert string `false` to boolean value false', function () {
(0, _expect.default)((0, _convertToProperType.default)('false', Boolean)).toBe(false);
(0, _expect["default"])((0, _convertToProperType["default"])('false', Boolean)).toBe(false);
});
it('convert string `FALSE` to boolean value false', function () {
(0, _expect.default)((0, _convertToProperType.default)('FALSE', Boolean)).toBe(false);
(0, _expect["default"])((0, _convertToProperType["default"])('FALSE', Boolean)).toBe(false);
});
it('convert string `true` to boolean value true', function () {
(0, _expect.default)((0, _convertToProperType.default)('true', Boolean)).toBe(true);
(0, _expect["default"])((0, _convertToProperType["default"])('true', Boolean)).toBe(true);
});
it('convert string `TRUE` to boolean value true', function () {
(0, _expect.default)((0, _convertToProperType.default)('TRUE', Boolean)).toBe(true);
(0, _expect["default"])((0, _convertToProperType["default"])('TRUE', Boolean)).toBe(true);
});
it('convert number 1 to boolean value true', function () {
(0, _expect.default)((0, _convertToProperType.default)(1, Boolean)).toBe(true);
(0, _expect["default"])((0, _convertToProperType["default"])(1, Boolean)).toBe(true);
});
it('convert number 0 to boolean value false', function () {
(0, _expect.default)((0, _convertToProperType.default)(0, Boolean)).toBe(false);
(0, _expect["default"])((0, _convertToProperType["default"])(0, Boolean)).toBe(false);
});
it('don\'t convert NaN to boolean value', function () {
(0, _expect.default)((0, _convertToProperType.default)(Number('text'), Boolean)).toEqual(NaN);
(0, _expect["default"])((0, _convertToProperType["default"])(Number('text'), Boolean)).toEqual(NaN);
});
it('does not try to convert null', function () {
(0, _expect.default)((0, _convertToProperType.default)(null, Array)).toBe(null);
(0, _expect["default"])((0, _convertToProperType["default"])(null, Array)).toBe(null);
});
});

@@ -7,3 +7,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -14,3 +14,3 @@ /* eslint-disable func-names, prefer-arrow-callback */

it('adds default value for missing top-level simple prop', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
name: {

@@ -22,4 +22,4 @@ type: String,

});
const result = schema.clean({});
(0, _expect.default)(result).toEqual({
var result = schema.clean({});
(0, _expect["default"])(result).toEqual({
name: 'Test'

@@ -29,3 +29,3 @@ });

it('does not add default value for already set top-level simple prop', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
name: {

@@ -37,6 +37,6 @@ type: String,

});
const result = schema.clean({
var result = schema.clean({
name: 'Other'
});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
name: 'Other'

@@ -46,3 +46,3 @@ });

it('adds default value for missing top-level array prop', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
names: {

@@ -55,4 +55,4 @@ type: Array,

});
const result = schema.clean({});
(0, _expect.default)(result).toEqual({
var result = schema.clean({});
(0, _expect["default"])(result).toEqual({
names: []

@@ -62,3 +62,3 @@ });

it('does not add default value for top-level array prop that is already set', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
names: {

@@ -71,6 +71,6 @@ type: Array,

});
const result = schema.clean({
var result = schema.clean({
names: ['foo', 'bar']
});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
names: ['foo', 'bar']

@@ -80,3 +80,3 @@ });

it('does not add defaultValue for prop in object, if object is not set', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
a: {

@@ -92,7 +92,7 @@ type: Object,

});
const result = schema.clean({});
(0, _expect.default)(result).toEqual({});
var result = schema.clean({});
(0, _expect["default"])(result).toEqual({});
});
it('adds defaultValue for prop in object, if object is set in object being cleaned', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
a: {

@@ -108,6 +108,6 @@ type: Object,

});
const result = schema.clean({
var result = schema.clean({
a: {}
});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
a: {

@@ -119,3 +119,3 @@ b: 'Test'

it('adds defaultValue for prop in objects within array, if object is set in object being cleaned', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
b: {

@@ -134,6 +134,6 @@ type: Array,

});
const result = schema.clean({
var result = schema.clean({
b: [{}, {}]
});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
b: [{

@@ -147,3 +147,3 @@ a: 'Test'

it('does not add defaultValue for prop in objects within array, if the prop is already set in object being cleaned', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
b: {

@@ -162,3 +162,3 @@ type: Array,

});
const result = schema.clean({
var result = schema.clean({
b: [{

@@ -168,3 +168,3 @@ a: 'Other'

});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
b: [{

@@ -176,3 +176,3 @@ a: 'Other'

it('adds defaultValue for prop in objects within array, if array and object are set by array defaultValue', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
b: {

@@ -194,4 +194,4 @@ type: Array,

});
const result = schema.clean({});
(0, _expect.default)(result).toEqual({
var result = schema.clean({});
(0, _expect["default"])(result).toEqual({
b: [{

@@ -205,3 +205,3 @@ a: 'Test'

it('adds defaultValue for prop in object, if object is set by another defaultValue', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
a: {

@@ -218,4 +218,4 @@ type: Object,

});
const result = schema.clean({});
(0, _expect.default)(result).toEqual({
var result = schema.clean({});
(0, _expect["default"])(result).toEqual({
a: {

@@ -227,3 +227,3 @@ b: 'Test'

it('does not add defaultValue for prop in object, if prop already has value in object being cleaned', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
a: {

@@ -239,3 +239,3 @@ type: Object,

});
const result = schema.clean({
var result = schema.clean({
a: {

@@ -245,3 +245,3 @@ b: 'Other'

});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
a: {

@@ -255,3 +255,3 @@ b: 'Other'

it('adds to $set object', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
obj: {

@@ -270,3 +270,3 @@ type: Object

});
const result = schema.clean({
var result = schema.clean({
$set: {

@@ -278,3 +278,3 @@ obj: {

});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
$set: {

@@ -289,3 +289,3 @@ obj: {

it('adds to $set object with dotted set prop', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
obj: {

@@ -309,3 +309,3 @@ type: Object

});
const result = schema.clean({
var result = schema.clean({
$set: {

@@ -318,3 +318,3 @@ 'obj.a': {}

});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
$set: {

@@ -331,3 +331,3 @@ 'obj.a': {

it('adds to $set object with dotted set prop and array', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
obj: {

@@ -351,3 +351,3 @@ type: Object

});
let result = schema.clean({
var result = schema.clean({
$set: {

@@ -357,3 +357,3 @@ 'obj.a': {}

});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
$set: {

@@ -370,3 +370,3 @@ 'obj.a': {}

});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
$set: {

@@ -385,3 +385,3 @@ 'obj.a': {

});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
$set: {

@@ -399,3 +399,3 @@ 'obj.a': {

it('adds a $setOnInsert if $setting a sibling prop', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
obj: {

@@ -419,3 +419,3 @@ type: Object

});
const result = schema.clean({
var result = schema.clean({
$set: {

@@ -429,3 +429,3 @@ 'obj.a': 100,

});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
$set: {

@@ -441,3 +441,3 @@ 'obj.a': 100,

it('adds a $setOnInsert if $setting a sibling child prop', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
obj: {

@@ -471,3 +471,3 @@ type: Object

});
const result = schema.clean({
var result = schema.clean({
$set: {

@@ -480,3 +480,3 @@ 'obj.a.one': 100

});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
$set: {

@@ -493,3 +493,3 @@ 'obj.a.one': 100

it('adds $setOnInsert for top-level prop', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -507,3 +507,3 @@ type: String,

});
const result = schema.clean({
var result = schema.clean({
$addToSet: {

@@ -516,3 +516,3 @@ names: 'new value'

});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
$addToSet: {

@@ -527,3 +527,3 @@ names: 'new value'

it('adds default values to object being $pushed into array', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
things: Array,

@@ -540,3 +540,3 @@ 'things.$': Object,

});
const result = schema.clean({
var result = schema.clean({
$push: {

@@ -546,3 +546,3 @@ things: {}

});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
$push: {

@@ -558,3 +558,3 @@ things: {

it('nested defaultValue for prop in obj in array', function () {
const listItemSchema = new _SimpleSchema.SimpleSchema({
var listItemSchema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -566,3 +566,3 @@ type: String,

});
const detailsSchema = new _SimpleSchema.SimpleSchema({
var detailsSchema = new _SimpleSchema.SimpleSchema({
list: {

@@ -574,3 +574,3 @@ type: Array,

});
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
name: String,

@@ -582,7 +582,7 @@ details: {

});
const cleanedObject = schema.clean({
var cleanedObject = schema.clean({
name: 'NAME',
details: {}
});
(0, _expect.default)(cleanedObject).toEqual({
(0, _expect["default"])(cleanedObject).toEqual({
name: 'NAME',

@@ -593,3 +593,3 @@ details: {}

it('issue 426', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
name: {

@@ -609,6 +609,6 @@ type: String

});
const doc = {
var doc = {
name: 'Test'
};
(0, _expect.default)(schema.clean(doc)).toEqual({
(0, _expect["default"])(schema.clean(doc)).toEqual({
name: 'Test',

@@ -618,4 +618,4 @@ images: []

});
it('complex with .$. modifier', () => {
const fooSchema = new _SimpleSchema.SimpleSchema({
it('complex with .$. modifier', function () {
var fooSchema = new _SimpleSchema.SimpleSchema({
bar: {

@@ -627,3 +627,3 @@ type: String,

});
const itemSchema = new _SimpleSchema.SimpleSchema({
var itemSchema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -634,3 +634,3 @@ type: fooSchema,

});
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
items: {

@@ -644,3 +644,3 @@ type: Array,

});
let result = schema.clean({
var result = schema.clean({
$set: {

@@ -652,3 +652,3 @@ 'items.$.foo': {

});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
$set: {

@@ -669,3 +669,3 @@ 'items.$.foo': {

});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
$addToSet: {

@@ -681,3 +681,3 @@ items: {

it('$setOnInsert are correctly added with path notation', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
settings: {

@@ -719,3 +719,3 @@ type: Object,

});
(0, _expect.default)(schema.clean({
(0, _expect["default"])(schema.clean({
$set: {

@@ -750,3 +750,3 @@ 'settings.obj.bool': true

// set on insert
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
settings: {

@@ -787,3 +787,3 @@ type: Object,

});
(0, _expect.default)(schema.clean({
(0, _expect["default"])(schema.clean({
$set: {

@@ -812,3 +812,3 @@ 'settings.obj.bool': true

it('default value for sibling field added by $addToSet', function () {
const AddressItem = new _SimpleSchema.SimpleSchema({
var AddressItem = new _SimpleSchema.SimpleSchema({
fullName: String,

@@ -818,3 +818,3 @@ address1: String,

});
const Profile = new _SimpleSchema.SimpleSchema({
var Profile = new _SimpleSchema.SimpleSchema({
addressBook: {

@@ -832,3 +832,3 @@ type: Array,

});
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
profile: {

@@ -839,3 +839,3 @@ type: Profile,

});
const accountsUpdateQuery = {
var accountsUpdateQuery = {
$addToSet: {

@@ -849,7 +849,7 @@ 'profile.addressBook': {

};
const cleanedModifier = schema.clean(accountsUpdateQuery, {
var cleanedModifier = schema.clean(accountsUpdateQuery, {
isModifier: true,
isUpsert: true
});
(0, _expect.default)(cleanedModifier).toEqual({
(0, _expect["default"])(cleanedModifier).toEqual({
$addToSet: {

@@ -868,3 +868,3 @@ 'profile.addressBook': {

it('does not add $setOnInsert to modifiers normally', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
name: String,

@@ -876,3 +876,3 @@ isOwner: {

});
(0, _expect.default)(schema.clean({
(0, _expect["default"])(schema.clean({
$set: {

@@ -890,3 +890,3 @@ name: 'Phil'

it('adds $setOnInsert to modifiers when isUpsert it true', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
name: String,

@@ -898,3 +898,3 @@ isOwner: {

});
(0, _expect.default)(schema.clean({
(0, _expect["default"])(schema.clean({
$set: {

@@ -901,0 +901,0 @@ name: 'Phil'

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = getPositionsForAutoValue;
exports["default"] = getPositionsForAutoValue;

@@ -13,3 +13,3 @@ var _mongoObject = _interopRequireDefault(require("mongo-object"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -41,9 +41,8 @@ /**

*/
function getPositionsForAutoValue({
fieldName,
isModifier,
mongoObject
}) {
function getPositionsForAutoValue(_ref) {
var fieldName = _ref.fieldName,
isModifier = _ref.isModifier,
mongoObject = _ref.mongoObject;
// Positions for this field
const positions = mongoObject.getPositionsInfoForGenericKey(fieldName); // If the field is an object and will be created by MongoDB,
var positions = mongoObject.getPositionsInfoForGenericKey(fieldName); // If the field is an object and will be created by MongoDB,
// we don't need (and can't have) a value for it

@@ -62,3 +61,3 @@

operator: isModifier ? '$set' : null,
position: isModifier ? `$set[${fieldName}]` : fieldName
position: isModifier ? "$set[".concat(fieldName, "]") : fieldName
});

@@ -68,14 +67,16 @@ return positions;

const parentPath = (0, _utility.getParentOfKey)(fieldName);
const lastPart = (0, _utility.getLastPartOfKey)(fieldName, parentPath);
const lastPartWithBraces = lastPart.replace(/\./g, '][');
const parentPositions = mongoObject.getPositionsInfoForGenericKey(parentPath);
var parentPath = (0, _utility.getParentOfKey)(fieldName);
var lastPart = (0, _utility.getLastPartOfKey)(fieldName, parentPath);
var lastPartWithBraces = lastPart.replace(/\./g, '][');
var parentPositions = mongoObject.getPositionsInfoForGenericKey(parentPath);
if (parentPositions.length) {
parentPositions.forEach(info => {
const childPosition = `${info.position}[${lastPartWithBraces}]`;
parentPositions.forEach(function (info) {
var childPosition = "".concat(info.position, "[").concat(lastPartWithBraces, "]");
if (!positions.find(i => i.position === childPosition)) {
if (!positions.find(function (i) {
return i.position === childPosition;
})) {
positions.push({
key: `${info.key}.${lastPart}`,
key: "".concat(info.key, ".").concat(lastPart),
value: undefined,

@@ -89,14 +90,12 @@ operator: info.operator,

// positions that will create parentPath
mongoObject.getPositionsThatCreateGenericKey(parentPath).forEach(info => {
const {
operator,
position
} = info;
let wouldBePosition;
mongoObject.getPositionsThatCreateGenericKey(parentPath).forEach(function (info) {
var operator = info.operator,
position = info.position;
var wouldBePosition;
if (operator) {
const next = position.slice(position.indexOf('[') + 1, position.indexOf(']'));
const nextPieces = next.split('.');
const newPieces = [];
let newKey;
var next = position.slice(position.indexOf('[') + 1, position.indexOf(']'));
var nextPieces = next.split('.');
var newPieces = [];
var newKey;

@@ -108,13 +107,15 @@ while (nextPieces.length && newKey !== parentPath) {

newKey = `${newKey}.${fieldName.slice(newKey.length + 1)}`;
wouldBePosition = `$set[${newKey}]`;
newKey = "".concat(newKey, ".").concat(fieldName.slice(newKey.length + 1));
wouldBePosition = "$set[".concat(newKey, "]");
} else {
const lastPart2 = (0, _utility.getLastPartOfKey)(fieldName, parentPath);
const lastPartWithBraces2 = lastPart2.replace(/\./g, '][');
wouldBePosition = `${position.slice(0, position.lastIndexOf('['))}[${lastPartWithBraces2}]`;
var lastPart2 = (0, _utility.getLastPartOfKey)(fieldName, parentPath);
var lastPartWithBraces2 = lastPart2.replace(/\./g, '][');
wouldBePosition = "".concat(position.slice(0, position.lastIndexOf('[')), "[").concat(lastPartWithBraces2, "]");
}
if (!positions.find(i => i.position === wouldBePosition)) {
if (!positions.find(function (i) {
return i.position === wouldBePosition;
})) {
positions.push({
key: _mongoObject.default._positionToKey(wouldBePosition),
key: _mongoObject["default"]._positionToKey(wouldBePosition),
value: undefined,

@@ -121,0 +122,0 @@ operator: operator ? '$set' : null,

@@ -7,3 +7,3 @@ "use strict";

exports.sortAutoValueFunctions = sortAutoValueFunctions;
exports.default = void 0;
exports["default"] = void 0;

@@ -14,3 +14,3 @@ var _getPositionsForAutoValue = _interopRequireDefault(require("./getPositionsForAutoValue"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -26,5 +26,4 @@ /**

function sortAutoValueFunctions(autoValueFunctions) {
const defaultFieldOrder = autoValueFunctions.reduce((acc, {
fieldName
}, index) => {
var defaultFieldOrder = autoValueFunctions.reduce(function (acc, _ref, index) {
var fieldName = _ref.fieldName;
acc[fieldName] = index;

@@ -36,4 +35,4 @@ return acc;

return autoValueFunctions.sort((a, b) => {
const depthDiff = a.fieldName.split('.').length - b.fieldName.split('.').length;
return autoValueFunctions.sort(function (a, b) {
var depthDiff = a.fieldName.split('.').length - b.fieldName.split('.').length;
return depthDiff === 0 ? defaultFieldOrder[a.fieldName] - defaultFieldOrder[b.fieldName] : depthDiff;

@@ -57,20 +56,19 @@ });

function setAutoValues(autoValueFunctions, mongoObject, isModifier, isUpsert, extendedAutoValueContext) {
const sortedAutoValueFunctions = sortAutoValueFunctions(autoValueFunctions);
sortedAutoValueFunctions.forEach(({
func,
fieldName,
closestSubschemaFieldName
}) => {
const avRunner = new _AutoValueRunner.default({
closestSubschemaFieldName,
extendedAutoValueContext,
func,
isModifier,
isUpsert,
mongoObject
var sortedAutoValueFunctions = sortAutoValueFunctions(autoValueFunctions);
sortedAutoValueFunctions.forEach(function (_ref2) {
var func = _ref2.func,
fieldName = _ref2.fieldName,
closestSubschemaFieldName = _ref2.closestSubschemaFieldName;
var avRunner = new _AutoValueRunner["default"]({
closestSubschemaFieldName: closestSubschemaFieldName,
extendedAutoValueContext: extendedAutoValueContext,
func: func,
isModifier: isModifier,
isUpsert: isUpsert,
mongoObject: mongoObject
});
const positions = (0, _getPositionsForAutoValue.default)({
fieldName,
isModifier,
mongoObject
var positions = (0, _getPositionsForAutoValue["default"])({
fieldName: fieldName,
isModifier: isModifier,
mongoObject: mongoObject
}); // Run the autoValue function once for each place in the object that

@@ -84,2 +82,2 @@ // has a value or that potentially should.

var _default = setAutoValues;
exports.default = _default;
exports["default"] = _default;

@@ -9,24 +9,18 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
describe('setAutoValues', () => {
it('sorts correctly', () => {
const schema = new _SimpleSchema.SimpleSchema({
describe('setAutoValues', function () {
it('sorts correctly', function () {
var schema = new _SimpleSchema.SimpleSchema({
field1: {
type: String,
autoValue() {}
autoValue: function autoValue() {}
},
field2: {
type: String,
autoValue() {}
autoValue: function autoValue() {}
},
field3: {
type: Number,
autoValue() {}
autoValue: function autoValue() {}
},

@@ -36,17 +30,11 @@ nested: Object,

type: String,
autoValue() {}
autoValue: function autoValue() {}
},
'nested.field2': {
type: String,
autoValue() {}
autoValue: function autoValue() {}
},
'nested.field3': {
type: String,
autoValue() {}
autoValue: function autoValue() {}
},

@@ -59,42 +47,35 @@ 'nested.field4': {

type: Number,
autoValue() {}
autoValue: function autoValue() {}
},
field5: {
type: Number,
autoValue() {}
autoValue: function autoValue() {}
},
field6: {
type: String,
autoValue() {}
autoValue: function autoValue() {}
},
field7: {
type: String,
autoValue() {}
autoValue: function autoValue() {}
}
});
const autoValueFunctions = schema.autoValueFunctions();
const sorted = (0, _setAutoValues.sortAutoValueFunctions)(autoValueFunctions);
const FIELD_COUNT = 7;
const NESTED_FIELD_COUNT = 4; // expecting: field1, field2, ..., field7, nested.field1, ... nested.field4
var autoValueFunctions = schema.autoValueFunctions();
var sorted = (0, _setAutoValues.sortAutoValueFunctions)(autoValueFunctions);
var FIELD_COUNT = 7;
var NESTED_FIELD_COUNT = 4; // expecting: field1, field2, ..., field7, nested.field1, ... nested.field4
const fieldOrder = sorted.map(({
fieldName
}) => fieldName);
var fieldOrder = sorted.map(function (_ref) {
var fieldName = _ref.fieldName;
return fieldName;
});
for (let i = 0; i < FIELD_COUNT; ++i) {
(0, _expect.default)(fieldOrder[i]).toBe(`field${i + 1}`);
for (var i = 0; i < FIELD_COUNT; ++i) {
(0, _expect["default"])(fieldOrder[i]).toBe("field".concat(i + 1));
}
for (let i = FIELD_COUNT; i < FIELD_COUNT + NESTED_FIELD_COUNT; ++i) {
(0, _expect.default)(fieldOrder[i]).toBe(`nested.field${i - FIELD_COUNT + 1}`);
for (var _i = FIELD_COUNT; _i < FIELD_COUNT + NESTED_FIELD_COUNT; ++_i) {
(0, _expect["default"])(fieldOrder[_i]).toBe("nested.field".concat(_i - FIELD_COUNT + 1));
}
});
});

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = void 0;
exports["default"] = void 0;

@@ -13,39 +13,39 @@ var _regExp = _interopRequireDefault(require("./regExp"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
const regExpMessages = [{
exp: _regExp.default.Email,
var regExpMessages = [{
exp: _regExp["default"].Email,
msg: 'must be a valid email address'
}, {
exp: _regExp.default.EmailWithTLD,
exp: _regExp["default"].EmailWithTLD,
msg: 'must be a valid email address'
}, {
exp: _regExp.default.Domain,
exp: _regExp["default"].Domain,
msg: 'must be a valid domain'
}, {
exp: _regExp.default.WeakDomain,
exp: _regExp["default"].WeakDomain,
msg: 'must be a valid domain'
}, {
exp: _regExp.default.IP,
exp: _regExp["default"].IP,
msg: 'must be a valid IPv4 or IPv6 address'
}, {
exp: _regExp.default.IPv4,
exp: _regExp["default"].IPv4,
msg: 'must be a valid IPv4 address'
}, {
exp: _regExp.default.IPv6,
exp: _regExp["default"].IPv6,
msg: 'must be a valid IPv6 address'
}, {
exp: _regExp.default.Url,
exp: _regExp["default"].Url,
msg: 'must be a valid URL'
}, {
exp: _regExp.default.Id,
exp: _regExp["default"].Id,
msg: 'must be a valid alphanumeric ID'
}, {
exp: _regExp.default.ZipCode,
exp: _regExp["default"].ZipCode,
msg: 'must be a valid ZIP code'
}, {
exp: _regExp.default.Phone,
exp: _regExp["default"].Phone,
msg: 'must be a valid phone number'
}];
const defaultMessages = {
var defaultMessages = {
initialLanguage: 'en',

@@ -69,18 +69,17 @@ messages: {

expectedType: '{{{label}}} must be of type {{dataType}}',
regEx({
label,
regExp
}) {
regEx: function regEx(_ref) {
var label = _ref.label,
regExp = _ref.regExp;
// See if there's one where exp matches this expression
let msgObj;
var msgObj;
if (regExp) {
msgObj = (0, _lodash.default)(regExpMessages, o => o.exp && o.exp.toString() === regExp);
msgObj = (0, _lodash["default"])(regExpMessages, function (o) {
return o.exp && o.exp.toString() === regExp;
});
}
const regExpMessage = msgObj ? msgObj.msg : 'failed regular expression validation';
return `${label} ${regExpMessage}`;
var regExpMessage = msgObj ? msgObj.msg : 'failed regular expression validation';
return "".concat(label, " ").concat(regExpMessage);
},
keyNotInSchema: '{{name}} is not allowed by the schema'

@@ -91,4 +90,4 @@ }

var _default = defaultMessages;
exports.default = _default;
exports["default"] = _default;
module.exports = exports.default;
module.exports.default = exports.default;

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = void 0;
exports["default"] = void 0;

@@ -29,6 +29,10 @@ var _mongoObject = _interopRequireDefault(require("mongo-object"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
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; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
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; }

@@ -41,15 +45,15 @@

function doValidation({
extendedCustomContext,
ignoreTypes,
isModifier,
isUpsert,
keysToValidate,
mongoObject,
obj,
schema,
validationContext
}) {
function doValidation(_ref) {
var extendedCustomContext = _ref.extendedCustomContext,
ignoreTypes = _ref.ignoreTypes,
isModifier = _ref.isModifier,
isUpsert = _ref.isUpsert,
keysToValidate = _ref.keysToValidate,
mongoObject = _ref.mongoObject,
obj = _ref.obj,
schema = _ref.schema,
validationContext = _ref.validationContext;
// First do some basic checks of the object, and throw errors if necessary
if (!(0, _lodash2.default)(obj)) {
if (!(0, _lodash2["default"])(obj)) {
throw new Error('The first argument of validate() must be an object');

@@ -62,3 +66,3 @@ }

let validationErrors = []; // Validation function called for each affected key
var validationErrors = []; // Validation function called for each affected key

@@ -89,9 +93,9 @@ function validate(val, affectedKey, affectedKeyGeneric, def, op, isInArrayItemObject, isInSubObject) {

const fieldParentNameWithEndDot = (0, _utility.getParentOfKey)(affectedKey, true);
const fieldParentName = fieldParentNameWithEndDot.slice(0, -1);
var fieldParentNameWithEndDot = (0, _utility.getParentOfKey)(affectedKey, true);
var fieldParentName = fieldParentNameWithEndDot.slice(0, -1);
function getFieldInfo(key) {
// Create mongoObject if necessary, cache for speed
if (!mongoObject) mongoObject = new _mongoObject.default(obj, schema.blackboxKeys());
const keyInfo = mongoObject.getInfoForKey(key) || {};
if (!mongoObject) mongoObject = new _mongoObject["default"](obj, schema.blackboxKeys());
var keyInfo = mongoObject.getInfoForKey(key) || {};
return {

@@ -104,31 +108,28 @@ isSet: keyInfo.value !== undefined,

const fieldValidationErrors = [];
var fieldValidationErrors = [];
const validatorContext = _objectSpread({
addValidationErrors(errors) {
errors.forEach(error => fieldValidationErrors.push(error));
var validatorContext = _objectSpread({
addValidationErrors: function addValidationErrors(errors) {
errors.forEach(function (error) {
return fieldValidationErrors.push(error);
});
},
field(fName) {
field: function field(fName) {
return getFieldInfo(fName);
},
genericKey: affectedKeyGeneric,
isInArrayItemObject,
isInSubObject,
isModifier,
isInArrayItemObject: isInArrayItemObject,
isInSubObject: isInSubObject,
isModifier: isModifier,
isSet: val !== undefined,
key: affectedKey,
obj,
obj: obj,
operator: op,
parentField() {
parentField: function parentField() {
return getFieldInfo(fieldParentName);
},
siblingField(fName) {
siblingField: function siblingField(fName) {
return getFieldInfo(fieldParentNameWithEndDot + fName);
},
validationContext,
validationContext: validationContext,
value: val,

@@ -140,11 +141,11 @@ // Value checks are not necessary for null or undefined values,

const builtInValidators = [_requiredValidator.default, _typeValidator.default, _allowedValuesValidator.default];
const validators = builtInValidators.concat(schema._validators).concat(_SimpleSchema.SimpleSchema._validators); // Loop through each of the definitions in the SimpleSchemaGroup.
var builtInValidators = [_requiredValidator["default"], _typeValidator["default"], _allowedValuesValidator["default"]];
var validators = builtInValidators.concat(schema._validators).concat(_SimpleSchema.SimpleSchema._validators); // Loop through each of the definitions in the SimpleSchemaGroup.
// If any return true, we're valid.
const fieldIsValid = def.type.some(typeDef => {
const finalValidatorContext = _objectSpread({}, validatorContext, {
var fieldIsValid = def.type.some(function (typeDef) {
var finalValidatorContext = _objectSpread({}, validatorContext, {
// Take outer definition props like "optional" and "label"
// and add them to inner props like "type" and "min"
definition: _objectSpread({}, (0, _lodash.default)(def, 'type'), typeDef)
definition: _objectSpread({}, (0, _lodash["default"])(def, 'type'), {}, typeDef)
}); // Add custom field validators to the list after the built-in

@@ -154,3 +155,3 @@ // validators but before the schema and global validators.

const fieldValidators = validators.slice(0);
var fieldValidators = validators.slice(0);

@@ -163,4 +164,4 @@ if (typeof typeDef.custom === 'function') {

return fieldValidators.every(validator => {
const result = validator.call(finalValidatorContext); // If the validator returns a string, assume it is the
return fieldValidators.every(function (validator) {
var result = validator.call(finalValidatorContext); // If the validator returns a string, assume it is the
// error type.

@@ -179,3 +180,3 @@

if (typeof result === 'object' && result !== null) {
if (_typeof(result) === 'object' && result !== null) {
fieldValidationErrors.push(_objectSpread({

@@ -202,11 +203,12 @@ name: affectedKey,

function checkObj({
val,
affectedKey,
operator,
isInArrayItemObject = false,
isInSubObject = false
}) {
let affectedKeyGeneric;
let def;
function checkObj(_ref2) {
var val = _ref2.val,
affectedKey = _ref2.affectedKey,
operator = _ref2.operator,
_ref2$isInArrayItemOb = _ref2.isInArrayItemObject,
isInArrayItemObject = _ref2$isInArrayItemOb === void 0 ? false : _ref2$isInArrayItemOb,
_ref2$isInSubObject = _ref2.isInSubObject,
isInSubObject = _ref2$isInSubObject === void 0 ? false : _ref2$isInSubObject;
var affectedKeyGeneric;
var def;

@@ -218,4 +220,6 @@ if (affectedKey) {

affectedKeyGeneric = _mongoObject.default.makeKeyGeneric(affectedKey);
const shouldValidateKey = !keysToValidate || keysToValidate.some(keyToValidate => keyToValidate === affectedKey || keyToValidate === affectedKeyGeneric || affectedKey.startsWith(`${keyToValidate}.`) || affectedKeyGeneric.startsWith(`${keyToValidate}.`)); // Perform validation for this key
affectedKeyGeneric = _mongoObject["default"].makeKeyGeneric(affectedKey);
var shouldValidateKey = !keysToValidate || keysToValidate.some(function (keyToValidate) {
return keyToValidate === affectedKey || keyToValidate === affectedKeyGeneric || affectedKey.startsWith("".concat(keyToValidate, ".")) || affectedKeyGeneric.startsWith("".concat(keyToValidate, "."));
}); // Perform validation for this key

@@ -231,3 +235,3 @@ def = schema.getDefinition(affectedKey);

const childKeys = schema.objectKeys(affectedKeyGeneric); // Temporarily convert missing objects to empty objects
var childKeys = schema.objectKeys(affectedKeyGeneric); // Temporarily convert missing objects to empty objects
// so that the looping code will be called and required

@@ -242,7 +246,7 @@ // descendent keys can be validated.

if (Array.isArray(val)) {
val.forEach((v, i) => {
val.forEach(function (v, i) {
checkObj({
val: v,
affectedKey: `${affectedKey}.${i}`,
operator
affectedKey: "".concat(affectedKey, ".").concat(i),
operator: operator
});

@@ -253,7 +257,7 @@ });

// Get list of present keys
const presentKeys = Object.keys(val); // Check all present keys plus all keys defined by the schema.
var presentKeys = Object.keys(val); // Check all present keys plus all keys defined by the schema.
// This allows us to detect extra keys not allowed by the schema plus
// any missing required keys, and to run any custom functions for other keys.
const keysToCheck = (0, _lodash3.default)(presentKeys, childKeys); // If this object is within an array, make sure we check for
var keysToCheck = (0, _lodash3["default"])(presentKeys, childKeys); // If this object is within an array, make sure we check for
// required as if it's not a modifier

@@ -263,8 +267,8 @@

keysToCheck.forEach(key => {
keysToCheck.forEach(function (key) {
checkObj({
val: val[key],
affectedKey: (0, _utility.appendAffectedKey)(affectedKey, key),
operator,
isInArrayItemObject,
operator: operator,
isInArrayItemObject: isInArrayItemObject,
isInSubObject: true

@@ -278,7 +282,7 @@ });

// Loop through operators
Object.keys(mod).forEach(op => {
const opObj = mod[op]; // If non-operators are mixed in, throw error
Object.keys(mod).forEach(function (op) {
var opObj = mod[op]; // If non-operators are mixed in, throw error
if (op.slice(0, 1) !== '$') {
throw new Error(`Expected '${op}' to be a modifier operator like '$set'`);
throw new Error("Expected '".concat(op, "' to be a modifier operator like '$set'"));
}

@@ -290,5 +294,5 @@

if (isUpsert && (op === '$set' || op === '$setOnInsert')) {
const presentKeys = Object.keys(opObj);
schema.objectKeys().forEach(schemaKey => {
if (!(0, _lodash4.default)(presentKeys, schemaKey)) {
var presentKeys = Object.keys(opObj);
schema.objectKeys().forEach(function (schemaKey) {
if (!(0, _lodash4["default"])(presentKeys, schemaKey)) {
checkObj({

@@ -305,10 +309,10 @@ val: undefined,

Object.keys(opObj).forEach(k => {
let v = opObj[k];
Object.keys(opObj).forEach(function (k) {
var v = opObj[k];
if (op === '$push' || op === '$addToSet') {
if (typeof v === 'object' && '$each' in v) {
if (_typeof(v) === 'object' && '$each' in v) {
v = v.$each;
} else {
k = `${k}.0`;
k = "".concat(k, ".0");
}

@@ -337,15 +341,15 @@ }

const docValidators = schema._docValidators.concat(_SimpleSchema.SimpleSchema._docValidators);
var docValidators = schema._docValidators.concat(_SimpleSchema.SimpleSchema._docValidators);
docValidators.forEach(func => {
const errors = func(obj);
docValidators.forEach(function (func) {
var errors = func(obj);
if (!Array.isArray(errors)) throw new Error('Custom doc validator must return an array of error objects');
if (errors.length) validationErrors = validationErrors.concat(errors);
});
const addedFieldNames = [];
validationErrors = validationErrors.filter(errObj => {
var addedFieldNames = [];
validationErrors = validationErrors.filter(function (errObj) {
// Remove error types the user doesn't care about
if ((0, _lodash4.default)(ignoreTypes, errObj.type)) return false; // Make sure there is only one error per fieldName
if ((0, _lodash4["default"])(ignoreTypes, errObj.type)) return false; // Make sure there is only one error per fieldName
if ((0, _lodash4.default)(addedFieldNames, errObj.name)) return false;
if ((0, _lodash4["default"])(addedFieldNames, errObj.name)) return false;
addedFieldNames.push(errObj.name);

@@ -358,4 +362,4 @@ return true;

var _default = doValidation;
exports.default = _default;
exports["default"] = _default;
module.exports = exports.default;
module.exports.default = exports.default;

@@ -6,10 +6,12 @@ "use strict";

});
exports.default = void 0;
exports["default"] = void 0;
var _mongoObject = _interopRequireDefault(require("mongo-object"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(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; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
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; }

@@ -21,7 +23,7 @@

function expandShorthand(schema) {
const schemaClone = {};
Object.keys(schema).forEach(key => {
const definition = schema[key]; // CASE 1: Not shorthand. Just clone
var schemaClone = {};
Object.keys(schema).forEach(function (key) {
var definition = schema[key]; // CASE 1: Not shorthand. Just clone
if (_mongoObject.default.isBasicObject(definition)) {
if (_mongoObject["default"].isBasicObject(definition)) {
schemaClone[key] = _objectSpread({}, definition);

@@ -34,6 +36,6 @@ return;

if (Array.isArray(definition[0])) {
throw new Error(`Array shorthand may only be used to one level of depth (${key})`);
throw new Error("Array shorthand may only be used to one level of depth (".concat(key, ")"));
}
const type = definition[0];
var type = definition[0];
schemaClone[key] = {

@@ -43,6 +45,6 @@ type: Array

const itemKey = `${key}.$`;
var itemKey = "".concat(key, ".$");
if (schema[itemKey]) {
throw new Error(`Array shorthand used for ${key} field but ${key}.$ key is already in the schema`);
throw new Error("Array shorthand used for ".concat(key, " field but ").concat(key, ".$ key is already in the schema"));
}

@@ -57,3 +59,3 @@

schemaClone[itemKey] = {
type
type: type
};

@@ -83,4 +85,4 @@ }

var _default = expandShorthand;
exports.default = _default;
exports["default"] = _default;
module.exports = exports.default;
module.exports.default = exports.default;

@@ -7,3 +7,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -13,3 +13,3 @@ /* eslint-disable func-names, prefer-arrow-callback */

it('test 1', function () {
const result = (0, _expandShorthand.default)({
var result = (0, _expandShorthand["default"])({
name: String,

@@ -19,3 +19,3 @@ count: Number,

});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
name: {

@@ -34,7 +34,7 @@ type: String

it('test 2', function () {
const result = (0, _expandShorthand.default)({
var result = (0, _expandShorthand["default"])({
name: [String],
count: [Number]
});
(0, _expect.default)(result).toEqual({
(0, _expect["default"])(result).toEqual({
name: {

@@ -41,0 +41,0 @@ type: Array

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = void 0;
exports["default"] = void 0;

@@ -39,4 +39,4 @@ /*

function extname(text) {
const index = text.lastIndexOf('.');
const ext = text.substring(index, text.length);
var index = text.lastIndexOf('.');
var ext = text.substring(index, text.length);
return index === -1 ? '' : ext;

@@ -57,4 +57,4 @@ }

var _default = humanize;
exports.default = _default;
exports["default"] = _default;
module.exports = exports.default;
module.exports.default = exports.default;

@@ -7,3 +7,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -13,19 +13,19 @@ /* eslint-disable func-names, prefer-arrow-callback */

it('works', function () {
(0, _expect.default)((0, _humanize.default)('super_snake_case')).toBe('Super snake case');
(0, _expect.default)((0, _humanize.default)('capitalizedCamelCase')).toBe('Capitalized camel case');
(0, _expect.default)((0, _humanize.default)('hyphen-case')).toBe('Hyphen case');
(0, _expect.default)((0, _humanize.default)('no-extensions-here.md')).toBe('No extensions here');
(0, _expect.default)((0, _humanize.default)('lower cased phrase')).toBe('Lower cased phrase');
(0, _expect.default)((0, _humanize.default)(' so many spaces ')).toBe('So many spaces');
(0, _expect.default)((0, _humanize.default)(123)).toBe('123');
(0, _expect.default)((0, _humanize.default)('')).toBe('');
(0, _expect.default)((0, _humanize.default)(null)).toBe('');
(0, _expect.default)((0, _humanize.default)(undefined)).toBe('');
(0, _expect.default)((0, _humanize.default)('externalSource')).toBe('External source');
(0, _expect.default)((0, _humanize.default)('externalSourceId')).toBe('External source ID');
(0, _expect.default)((0, _humanize.default)('externalSource_id')).toBe('External source ID');
(0, _expect.default)((0, _humanize.default)('_id')).toBe('ID'); // Make sure it does not mess with "id" in the middle of a word
(0, _expect["default"])((0, _humanize["default"])('super_snake_case')).toBe('Super snake case');
(0, _expect["default"])((0, _humanize["default"])('capitalizedCamelCase')).toBe('Capitalized camel case');
(0, _expect["default"])((0, _humanize["default"])('hyphen-case')).toBe('Hyphen case');
(0, _expect["default"])((0, _humanize["default"])('no-extensions-here.md')).toBe('No extensions here');
(0, _expect["default"])((0, _humanize["default"])('lower cased phrase')).toBe('Lower cased phrase');
(0, _expect["default"])((0, _humanize["default"])(' so many spaces ')).toBe('So many spaces');
(0, _expect["default"])((0, _humanize["default"])(123)).toBe('123');
(0, _expect["default"])((0, _humanize["default"])('')).toBe('');
(0, _expect["default"])((0, _humanize["default"])(null)).toBe('');
(0, _expect["default"])((0, _humanize["default"])(undefined)).toBe('');
(0, _expect["default"])((0, _humanize["default"])('externalSource')).toBe('External source');
(0, _expect["default"])((0, _humanize["default"])('externalSourceId')).toBe('External source ID');
(0, _expect["default"])((0, _humanize["default"])('externalSource_id')).toBe('External source ID');
(0, _expect["default"])((0, _humanize["default"])('_id')).toBe('ID'); // Make sure it does not mess with "id" in the middle of a word
(0, _expect.default)((0, _humanize.default)('overridden')).toBe('Overridden');
(0, _expect["default"])((0, _humanize["default"])('overridden')).toBe('Overridden');
});
});

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = void 0;
exports["default"] = void 0;

@@ -15,4 +15,4 @@ var _SimpleSchema = require("./SimpleSchema");

var _default = _SimpleSchema.SimpleSchema;
exports.default = _default;
exports["default"] = _default;
module.exports = exports.default;
module.exports.default = exports.default;

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = void 0;
exports["default"] = void 0;
// this domain regex matches all domains that have at least one .

@@ -12,10 +12,10 @@ // sadly IPv4 Adresses will be caught too but technically those are valid domains

// a modification enforces that the tld consists only of characters
const rxDomain = '(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z](?:[a-z-]*[a-z])?'; // this domain regex matches everythign that could be a domain in intranet
var rxDomain = '(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z](?:[a-z-]*[a-z])?'; // this domain regex matches everythign that could be a domain in intranet
// that means "localhost" is a valid domain
const rxNameDomain = '(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\.|$))+'; // strict IPv4 expression which allows 0-255 per oktett
var rxNameDomain = '(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\.|$))+'; // strict IPv4 expression which allows 0-255 per oktett
const rxIPv4 = '(?:(?:[0-1]?\\d{1,2}|2[0-4]\\d|25[0-5])(?:\\.|$)){4}'; // strict IPv6 expression which allows (and validates) all shortcuts
var rxIPv4 = '(?:(?:[0-1]?\\d{1,2}|2[0-4]\\d|25[0-5])(?:\\.|$)){4}'; // strict IPv6 expression which allows (and validates) all shortcuts
const rxIPv6 = '(?:(?:[\\dA-Fa-f]{1,4}(?::|$)){8}' // full adress
var rxIPv6 = '(?:(?:[\\dA-Fa-f]{1,4}(?::|$)){8}' // full adress
+ '|(?=(?:[^:\\s]|:[^:\\s])*::(?:[^:\\s]|:[^:\\s])*$)' // or min/max one '::'

@@ -25,4 +25,4 @@ + '[\\dA-Fa-f]{0,4}(?:::?(?:[\\dA-Fa-f]{1,4}|$)){1,6})'; // and short adress

const rxWeakDomain = `(?:${[rxNameDomain, rxIPv4, rxIPv6].join('|')})`;
const regEx = {
var rxWeakDomain = "(?:".concat([rxNameDomain, rxIPv4, rxIPv6].join('|'), ")");
var regEx = {
// We use the RegExp suggested by W3C in http://www.w3.org/TR/html5/forms.html#valid-e-mail-address

@@ -34,7 +34,7 @@ // This is probably the same logic used by most browsers when type=email, which is our goal. It is

EmailWithTLD: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
Domain: new RegExp(`^${rxDomain}$`),
WeakDomain: new RegExp(`^${rxWeakDomain}$`),
IP: new RegExp(`^(?:${rxIPv4}|${rxIPv6})$`),
IPv4: new RegExp(`^${rxIPv4}$`),
IPv6: new RegExp(`^${rxIPv6}$`),
Domain: new RegExp("^".concat(rxDomain, "$")),
WeakDomain: new RegExp("^".concat(rxWeakDomain, "$")),
IP: new RegExp("^(?:".concat(rxIPv4, "|").concat(rxIPv6, ")$")),
IPv4: new RegExp("^".concat(rxIPv4, "$")),
IPv6: new RegExp("^".concat(rxIPv6, "$")),
// URL RegEx from https://gist.github.com/dperini/729294

@@ -58,4 +58,4 @@ // http://mathiasbynens.be/demo/url-regex

var _default = regEx;
exports.default = _default;
exports["default"] = _default;
module.exports = exports.default;
module.exports.default = exports.default;

@@ -15,3 +15,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -22,13 +22,13 @@ /* eslint-disable func-names, prefer-arrow-callback */

it('valid string', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
allowedStrings: 'tuna'
}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
allowedStringsArray: ['tuna', 'fish', 'salad']
}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
allowedStringsSet: ['tuna', 'fish', 'salad']
}).toEqual(0); // Array of objects
(0, _expectErrorLength.default)(_friendsSchema.default, {
(0, _expectErrorLength["default"])(_friendsSchema["default"], {
friends: [{

@@ -42,15 +42,15 @@ name: 'Bob',

it('invalid string', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
allowedStrings: 'tunas'
}).toEqual(1); // Array
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
allowedStringsArray: ['tuna', 'fish', 'sandwich']
}).toEqual(1); // Set Or Array
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
allowedStringsSet: ['tuna', 'fish', 'sandwich']
}).toEqual(1); // Array of objects
(0, _expectErrorLength.default)(_friendsSchema.default, {
(0, _expectErrorLength["default"])(_friendsSchema["default"], {
friends: [{

@@ -64,13 +64,13 @@ name: 'Bob',

it('valid number', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
allowedNumbers: 1
}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
allowedNumbersArray: [1, 2, 3]
}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
allowedNumbersSet: [1, 2, 3]
}).toEqual(0); // Array of objects
(0, _expectErrorLength.default)(_friendsSchema.default, {
(0, _expectErrorLength["default"])(_friendsSchema["default"], {
friends: [{

@@ -87,15 +87,15 @@ name: 'Bob',

it('invalid number', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
allowedNumbers: 4
}).toEqual(1); // Array
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
allowedNumbersArray: [1, 2, 3, 4]
}).toEqual(1); // Set or Array
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
allowedNumbersSet: [1, 2, 3, 4]
}).toEqual(1); // Array of objects
(0, _expectErrorLength.default)(_friendsSchema.default, {
(0, _expectErrorLength["default"])(_friendsSchema["default"], {
friends: [{

@@ -114,3 +114,3 @@ name: 'Bob',

it('valid string', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -124,3 +124,3 @@ allowedStrings: 'tuna'

(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -134,3 +134,3 @@ allowedStringsArray: ['tuna', 'fish', 'salad']

(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -144,3 +144,3 @@ allowedStringsSet: ['tuna', 'fish', 'salad']

(0, _expectErrorLength.default)(_friendsSchema.default, {
(0, _expectErrorLength["default"])(_friendsSchema["default"], {
$setOnInsert: {

@@ -159,3 +159,3 @@ friends: [{

it('invalid string', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -169,3 +169,3 @@ allowedStrings: 'tunas'

(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -179,3 +179,3 @@ allowedStringsArray: ['tuna', 'fish', 'sandwich']

(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -189,3 +189,3 @@ allowedStringsSet: ['tuna', 'fish', 'sandwich']

(0, _expectErrorLength.default)(_friendsSchema.default, {
(0, _expectErrorLength["default"])(_friendsSchema["default"], {
$setOnInsert: {

@@ -204,3 +204,3 @@ friends: [{

it('valid number', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -214,3 +214,3 @@ allowedNumbers: 1

(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -224,3 +224,3 @@ allowedNumbersArray: [1, 2, 3]

(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -234,3 +234,3 @@ allowedNumbersSet: [1, 2, 3]

(0, _expectErrorLength.default)(_friendsSchema.default, {
(0, _expectErrorLength["default"])(_friendsSchema["default"], {
$setOnInsert: {

@@ -252,3 +252,3 @@ friends: [{

it('invalid number', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -262,3 +262,3 @@ allowedNumbers: 4

(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -272,3 +272,3 @@ allowedNumbersArray: [1, 2, 3, 4]

(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -282,3 +282,3 @@ allowedNumbersSet: [1, 2, 3, 4]

(0, _expectErrorLength.default)(_friendsSchema.default, {
(0, _expectErrorLength["default"])(_friendsSchema["default"], {
$setOnInsert: {

@@ -302,3 +302,3 @@ friends: [{

it('valid string', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -311,3 +311,3 @@ allowedStrings: 'tuna'

(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -320,3 +320,3 @@ allowedStringsArray: ['tuna', 'fish', 'salad']

(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -329,3 +329,3 @@ allowedStringsSet: ['tuna', 'fish', 'salad']

(0, _expectErrorLength.default)(_friendsSchema.default, {
(0, _expectErrorLength["default"])(_friendsSchema["default"], {
$set: {

@@ -337,3 +337,3 @@ 'friends.$.name': 'Bob'

}).toEqual(0);
(0, _expectErrorLength.default)(_friendsSchema.default, {
(0, _expectErrorLength["default"])(_friendsSchema["default"], {
$set: {

@@ -347,3 +347,3 @@ 'friends.1.name': 'Bob'

it('invalid string', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -356,3 +356,3 @@ allowedStrings: 'tunas'

(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -365,3 +365,3 @@ allowedStringsArray: ['tuna', 'fish', 'sandwich']

(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -374,3 +374,3 @@ allowedStringsSet: ['tuna', 'fish', 'sandwich']

(0, _expectErrorLength.default)(_friendsSchema.default, {
(0, _expectErrorLength["default"])(_friendsSchema["default"], {
$set: {

@@ -382,3 +382,3 @@ 'friends.$.name': 'Bobby'

}).toEqual(1);
(0, _expectErrorLength.default)(_friendsSchema.default, {
(0, _expectErrorLength["default"])(_friendsSchema["default"], {
$set: {

@@ -392,3 +392,3 @@ 'friends.1.name': 'Bobby'

it('valid number', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -400,3 +400,3 @@ allowedNumbers: 1

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -408,3 +408,3 @@ allowedNumbersArray: [1, 2, 3]

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -418,3 +418,3 @@ allowedNumbersSet: [1, 2, 3]

it('invalid number', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -426,3 +426,3 @@ allowedNumbers: 4

}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -434,3 +434,3 @@ allowedNumbersArray: [1, 2, 3, 4]

}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -446,28 +446,28 @@ allowedNumbersSet: [1, 2, 3, 4]

it('works', function () {
const allowedValues = ['a', 'b'];
const schema = new _SimpleSchema.SimpleSchema({
var allowedValues = ['a', 'b'];
var schema = new _SimpleSchema.SimpleSchema({
foo: Array,
'foo.$': {
type: String,
allowedValues
allowedValues: allowedValues
}
});
(0, _expect.default)(schema.getAllowedValuesForKey('foo')).toEqual(allowedValues);
(0, _expect["default"])(schema.getAllowedValuesForKey('foo')).toEqual(allowedValues);
});
it('works with set, convert to array', function () {
const allowedValues = new Set(['a', 'b']);
const schema = new _SimpleSchema.SimpleSchema({
var allowedValues = new Set(['a', 'b']);
var schema = new _SimpleSchema.SimpleSchema({
foo: Array,
'foo.$': {
type: String,
allowedValues
allowedValues: allowedValues
}
});
const fetchedAllowedValues = schema.getAllowedValuesForKey('foo');
(0, _expect.default)(fetchedAllowedValues).toInclude('a');
(0, _expect.default)(fetchedAllowedValues).toInclude('b');
(0, _expect.default)(fetchedAllowedValues.length).toEqual(2);
var fetchedAllowedValues = schema.getAllowedValuesForKey('foo');
(0, _expect["default"])(fetchedAllowedValues).toInclude('a');
(0, _expect["default"])(fetchedAllowedValues).toInclude('b');
(0, _expect["default"])(fetchedAllowedValues.length).toEqual(2);
});
it('returns null when allowedValues key is empty', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: Array,

@@ -478,5 +478,5 @@ 'foo.$': {

});
(0, _expect.default)(schema.getAllowedValuesForKey('foo')).toEqual(null);
(0, _expect["default"])(schema.getAllowedValuesForKey('foo')).toEqual(null);
});
});
});

@@ -7,3 +7,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -13,37 +13,29 @@ /* eslint-disable func-names, prefer-arrow-callback */

it('simple', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
a: {
type: String,
autoValue() {}
autoValue: function autoValue() {}
}
});
const autoValueFunctions = schema.autoValueFunctions();
(0, _expect.default)(autoValueFunctions.length).toBe(1);
(0, _expect.default)(!!autoValueFunctions[0].func).toBe(true);
(0, _expect.default)(autoValueFunctions[0].fieldName).toBe('a');
(0, _expect.default)(autoValueFunctions[0].closestSubschemaFieldName).toBe('');
var autoValueFunctions = schema.autoValueFunctions();
(0, _expect["default"])(autoValueFunctions.length).toBe(1);
(0, _expect["default"])(!!autoValueFunctions[0].func).toBe(true);
(0, _expect["default"])(autoValueFunctions[0].fieldName).toBe('a');
(0, _expect["default"])(autoValueFunctions[0].closestSubschemaFieldName).toBe('');
});
it('one level of subschema', function () {
const subschema = new _SimpleSchema.SimpleSchema({
var subschema = new _SimpleSchema.SimpleSchema({
z: {
type: Object,
autoValue() {}
autoValue: function autoValue() {}
}
});
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
a: {
type: Object,
autoValue() {}
autoValue: function autoValue() {}
},
'a.b': {
type: String,
autoValue() {}
autoValue: function autoValue() {}
},

@@ -54,27 +46,23 @@ c: {

});
const autoValueFunctions = schema.autoValueFunctions();
(0, _expect.default)(autoValueFunctions.length).toBe(3);
(0, _expect.default)(!!autoValueFunctions[0].func).toBe(true);
(0, _expect.default)(autoValueFunctions[0].fieldName).toBe('a');
(0, _expect.default)(autoValueFunctions[0].closestSubschemaFieldName).toBe('');
(0, _expect.default)(!!autoValueFunctions[1].func).toBe(true);
(0, _expect.default)(autoValueFunctions[1].fieldName).toBe('a.b');
(0, _expect.default)(autoValueFunctions[1].closestSubschemaFieldName).toBe('');
(0, _expect.default)(!!autoValueFunctions[2].func).toBe(true);
(0, _expect.default)(autoValueFunctions[2].fieldName).toBe('c.z');
(0, _expect.default)(autoValueFunctions[2].closestSubschemaFieldName).toBe('c');
var autoValueFunctions = schema.autoValueFunctions();
(0, _expect["default"])(autoValueFunctions.length).toBe(3);
(0, _expect["default"])(!!autoValueFunctions[0].func).toBe(true);
(0, _expect["default"])(autoValueFunctions[0].fieldName).toBe('a');
(0, _expect["default"])(autoValueFunctions[0].closestSubschemaFieldName).toBe('');
(0, _expect["default"])(!!autoValueFunctions[1].func).toBe(true);
(0, _expect["default"])(autoValueFunctions[1].fieldName).toBe('a.b');
(0, _expect["default"])(autoValueFunctions[1].closestSubschemaFieldName).toBe('');
(0, _expect["default"])(!!autoValueFunctions[2].func).toBe(true);
(0, _expect["default"])(autoValueFunctions[2].fieldName).toBe('c.z');
(0, _expect["default"])(autoValueFunctions[2].closestSubschemaFieldName).toBe('c');
});
it('two levels of subschemas', function () {
const subschema1 = new _SimpleSchema.SimpleSchema({
var subschema1 = new _SimpleSchema.SimpleSchema({
x: {
type: Object,
autoValue() {}
autoValue: function autoValue() {}
},
'x.m': {
type: Array,
autoValue() {}
autoValue: function autoValue() {}
},

@@ -85,8 +73,6 @@ 'x.m.$': {

});
const subschema2 = new _SimpleSchema.SimpleSchema({
var subschema2 = new _SimpleSchema.SimpleSchema({
z: {
type: Object,
autoValue() {}
autoValue: function autoValue() {}
},

@@ -97,14 +83,10 @@ 'z.y': {

});
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
a: {
type: Object,
autoValue() {}
autoValue: function autoValue() {}
},
'a.b': {
type: String,
autoValue() {}
autoValue: function autoValue() {}
},

@@ -115,35 +97,31 @@ c: {

});
const autoValueFunctions = schema.autoValueFunctions();
(0, _expect.default)(autoValueFunctions.length).toBe(5);
(0, _expect.default)(!!autoValueFunctions[0].func).toBe(true);
(0, _expect.default)(autoValueFunctions[0].fieldName).toBe('a');
(0, _expect.default)(autoValueFunctions[0].closestSubschemaFieldName).toBe('');
(0, _expect.default)(!!autoValueFunctions[1].func).toBe(true);
(0, _expect.default)(autoValueFunctions[1].fieldName).toBe('a.b');
(0, _expect.default)(autoValueFunctions[1].closestSubschemaFieldName).toBe('');
(0, _expect.default)(!!autoValueFunctions[2].func).toBe(true);
(0, _expect.default)(autoValueFunctions[2].fieldName).toBe('c.z');
(0, _expect.default)(autoValueFunctions[2].closestSubschemaFieldName).toBe('c');
(0, _expect.default)(!!autoValueFunctions[3].func).toBe(true);
(0, _expect.default)(autoValueFunctions[3].fieldName).toBe('c.z.y.x');
(0, _expect.default)(autoValueFunctions[3].closestSubschemaFieldName).toBe('c.z.y');
(0, _expect.default)(!!autoValueFunctions[4].func).toBe(true);
(0, _expect.default)(autoValueFunctions[4].fieldName).toBe('c.z.y.x.m');
(0, _expect.default)(autoValueFunctions[4].closestSubschemaFieldName).toBe('c.z.y');
var autoValueFunctions = schema.autoValueFunctions();
(0, _expect["default"])(autoValueFunctions.length).toBe(5);
(0, _expect["default"])(!!autoValueFunctions[0].func).toBe(true);
(0, _expect["default"])(autoValueFunctions[0].fieldName).toBe('a');
(0, _expect["default"])(autoValueFunctions[0].closestSubschemaFieldName).toBe('');
(0, _expect["default"])(!!autoValueFunctions[1].func).toBe(true);
(0, _expect["default"])(autoValueFunctions[1].fieldName).toBe('a.b');
(0, _expect["default"])(autoValueFunctions[1].closestSubschemaFieldName).toBe('');
(0, _expect["default"])(!!autoValueFunctions[2].func).toBe(true);
(0, _expect["default"])(autoValueFunctions[2].fieldName).toBe('c.z');
(0, _expect["default"])(autoValueFunctions[2].closestSubschemaFieldName).toBe('c');
(0, _expect["default"])(!!autoValueFunctions[3].func).toBe(true);
(0, _expect["default"])(autoValueFunctions[3].fieldName).toBe('c.z.y.x');
(0, _expect["default"])(autoValueFunctions[3].closestSubschemaFieldName).toBe('c.z.y');
(0, _expect["default"])(!!autoValueFunctions[4].func).toBe(true);
(0, _expect["default"])(autoValueFunctions[4].fieldName).toBe('c.z.y.x.m');
(0, _expect["default"])(autoValueFunctions[4].closestSubschemaFieldName).toBe('c.z.y');
});
it('array of objects', function () {
const subschema = new _SimpleSchema.SimpleSchema({
var subschema = new _SimpleSchema.SimpleSchema({
z: {
type: String,
autoValue() {}
autoValue: function autoValue() {}
}
});
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
a: {
type: Object,
autoValue() {}
autoValue: function autoValue() {}
},

@@ -157,11 +135,11 @@ 'a.b': {

});
const autoValueFunctions = schema.autoValueFunctions();
(0, _expect.default)(autoValueFunctions.length).toBe(2);
(0, _expect.default)(!!autoValueFunctions[0].func).toBe(true);
(0, _expect.default)(autoValueFunctions[0].fieldName).toBe('a');
(0, _expect.default)(autoValueFunctions[0].closestSubschemaFieldName).toBe('');
(0, _expect.default)(!!autoValueFunctions[1].func).toBe(true);
(0, _expect.default)(autoValueFunctions[1].fieldName).toBe('a.b.$.z');
(0, _expect.default)(autoValueFunctions[1].closestSubschemaFieldName).toBe('a.b.$');
var autoValueFunctions = schema.autoValueFunctions();
(0, _expect["default"])(autoValueFunctions.length).toBe(2);
(0, _expect["default"])(!!autoValueFunctions[0].func).toBe(true);
(0, _expect["default"])(autoValueFunctions[0].fieldName).toBe('a');
(0, _expect["default"])(autoValueFunctions[0].closestSubschemaFieldName).toBe('');
(0, _expect["default"])(!!autoValueFunctions[1].func).toBe(true);
(0, _expect["default"])(autoValueFunctions[1].fieldName).toBe('a.b.$.z');
(0, _expect["default"])(autoValueFunctions[1].closestSubschemaFieldName).toBe('a.b.$');
});
});

@@ -7,6 +7,6 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
/* eslint-disable func-names, prefer-arrow-callback */
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
blackBoxObject: {

@@ -20,3 +20,3 @@ type: Object,

it('allows an empty object', function () {
(0, _expectErrorLength.default)(schema, {
(0, _expectErrorLength["default"])(schema, {
blackBoxObject: {}

@@ -26,3 +26,3 @@ }).toEqual(0);

it('allows any properties', function () {
(0, _expectErrorLength.default)(schema, {
(0, _expectErrorLength["default"])(schema, {
blackBoxObject: {

@@ -34,3 +34,3 @@ foo: 'bar'

it('allows any properties on $set object', function () {
(0, _expectErrorLength.default)(schema, {
(0, _expectErrorLength["default"])(schema, {
$set: {

@@ -46,3 +46,3 @@ blackBoxObject: {

it('allows to $set any subobject', function () {
(0, _expectErrorLength.default)(schema, {
(0, _expectErrorLength["default"])(schema, {
$set: {

@@ -54,3 +54,3 @@ 'blackBoxObject.foo': 'bar'

}).toEqual(0);
(0, _expectErrorLength.default)(schema, {
(0, _expectErrorLength["default"])(schema, {
$set: {

@@ -64,3 +64,3 @@ 'blackBoxObject.1': 'bar'

it('allows to $push into any subobject', function () {
(0, _expectErrorLength.default)(schema, {
(0, _expectErrorLength["default"])(schema, {
$push: {

@@ -67,0 +67,0 @@ 'blackBoxObject.foo': 'bar'

@@ -11,6 +11,6 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
/* eslint-disable func-names, prefer-arrow-callback */
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
password: {

@@ -21,4 +21,3 @@ type: String

type: String,
custom() {
custom: function custom() {
if (this.value !== this.field('password').value) {

@@ -28,33 +27,24 @@ return 'passwordMismatch';

}
}
});
const requiredCustomSchema = new _SimpleSchema.SimpleSchema({
var requiredCustomSchema = new _SimpleSchema.SimpleSchema({
a: {
type: Array,
custom() {// Just adding custom to trigger extra validation
custom: function custom() {// Just adding custom to trigger extra validation
}
},
'a.$': {
type: Object,
custom() {// Just adding custom to trigger extra validation
custom: function custom() {// Just adding custom to trigger extra validation
}
},
b: {
type: Array,
custom() {// Just adding custom to trigger extra validation
custom: function custom() {// Just adding custom to trigger extra validation
}
},
'b.$': {
type: Object,
custom() {// Just adding custom to trigger extra validation
custom: function custom() {// Just adding custom to trigger extra validation
}
}

@@ -65,3 +55,3 @@ });

it('valid', function () {
(0, _expectErrorLength.default)(schema, {
(0, _expectErrorLength["default"])(schema, {
password: 'password',

@@ -72,3 +62,3 @@ confirmPassword: 'password'

it('invalid', function () {
(0, _expectErrorOfTypeLength.default)('passwordMismatch', schema, {
(0, _expectErrorOfTypeLength["default"])('passwordMismatch', schema, {
password: 'password',

@@ -81,3 +71,3 @@ confirmPassword: 'password1'

it('valid', function () {
(0, _expectErrorLength.default)(schema, {
(0, _expectErrorLength["default"])(schema, {
$setOnInsert: {

@@ -93,3 +83,3 @@ password: 'password',

it('invalid', function () {
(0, _expectErrorOfTypeLength.default)('passwordMismatch', schema, {
(0, _expectErrorOfTypeLength["default"])('passwordMismatch', schema, {
$setOnInsert: {

@@ -107,3 +97,3 @@ password: 'password',

it('valid', function () {
(0, _expectErrorLength.default)(schema, {
(0, _expectErrorLength["default"])(schema, {
$set: {

@@ -118,3 +108,3 @@ password: 'password',

it('invalid', function () {
(0, _expectErrorOfTypeLength.default)('passwordMismatch', schema, {
(0, _expectErrorOfTypeLength["default"])('passwordMismatch', schema, {
$set: {

@@ -132,29 +122,29 @@ password: 'password',

it('custom validator has this.validationContext set', function () {
let ok = false;
const customSchema = new _SimpleSchema.SimpleSchema({
var ok = false;
var customSchema = new _SimpleSchema.SimpleSchema({
foo: {
type: String,
optional: true,
custom() {
custom: function custom() {
if (this.validationContext instanceof _SimpleSchema.ValidationContext) ok = true;
}
}
});
customSchema.namedContext().validate({});
(0, _expect.default)(ok).toBe(true);
(0, _expect["default"])(ok).toBe(true);
});
it('custom validation runs even when the optional field is undefined', function () {
const customSchema = new _SimpleSchema.SimpleSchema({
var customSchema = new _SimpleSchema.SimpleSchema({
foo: {
type: String,
optional: true,
custom: () => 'custom'
custom: function custom() {
return 'custom';
}
}
});
const context = customSchema.namedContext();
var context = customSchema.namedContext();
context.validate({});
(0, _expect.default)(context.validationErrors().length).toEqual(1);
(0, _expect.default)(context.validationErrors()[0]).toEqual({
(0, _expect["default"])(context.validationErrors().length).toEqual(1);
(0, _expect["default"])(context.validationErrors()[0]).toEqual({
name: 'foo',

@@ -166,10 +156,12 @@ type: 'custom',

it('custom validation runs when string is unset', function () {
const customSchema = new _SimpleSchema.SimpleSchema({
var customSchema = new _SimpleSchema.SimpleSchema({
foo: {
type: String,
optional: true,
custom: () => 'custom'
custom: function custom() {
return 'custom';
}
}
});
const context = customSchema.namedContext();
var context = customSchema.namedContext();
context.validate({

@@ -182,4 +174,4 @@ $unset: {

});
(0, _expect.default)(context.validationErrors().length).toEqual(1);
(0, _expect.default)(context.validationErrors()[0]).toEqual({
(0, _expect["default"])(context.validationErrors().length).toEqual(1);
(0, _expect["default"])(context.validationErrors()[0]).toEqual({
name: 'foo',

@@ -191,4 +183,4 @@ type: 'custom',

it('we do not get required errors for a required field that has a `custom` function when we are $setting', function () {
const context = requiredCustomSchema.namedContext();
(0, _expect.default)(context.validate({
var context = requiredCustomSchema.namedContext();
(0, _expect["default"])(context.validate({
$set: {

@@ -200,3 +192,3 @@ a: [{}]

})).toEqual(true);
(0, _expect.default)(context.validate({
(0, _expect["default"])(context.validate({
$set: {

@@ -210,4 +202,4 @@ 'a.0': {}

it('we do not get required errors for a required field that has a `custom` function when we are $pushing', function () {
const context = requiredCustomSchema.namedContext();
(0, _expect.default)(context.validate({
var context = requiredCustomSchema.namedContext();
(0, _expect["default"])(context.validate({
$push: {

@@ -214,0 +206,0 @@ a: {}

@@ -7,3 +7,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -13,4 +13,4 @@ /* eslint-disable func-names, prefer-arrow-callback */

it('throws an error when the schema definition includes an unrecognized key', function () {
(0, _expect.default)(() => {
const schema = new _SimpleSchema.SimpleSchema({
(0, _expect["default"])(function () {
var schema = new _SimpleSchema.SimpleSchema({
// eslint-disable-line no-unused-vars

@@ -29,4 +29,4 @@ name: {

(0, _expect.default)(() => {
const schema = new _SimpleSchema.SimpleSchema({
(0, _expect["default"])(function () {
var schema = new _SimpleSchema.SimpleSchema({
// eslint-disable-line no-unused-vars

@@ -33,0 +33,0 @@ name: {

@@ -7,3 +7,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -14,3 +14,3 @@ /* eslint-disable func-names, prefer-arrow-callback */

it('top level object', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: Object,

@@ -29,4 +29,4 @@ 'foo.aaa': {

});
const newSchema = schema.getObjectSchema('foo');
(0, _expect.default)(newSchema.mergedSchema()).toEqual({
var newSchema = schema.getObjectSchema('foo');
(0, _expect["default"])(newSchema.mergedSchema()).toEqual({
aaa: {

@@ -50,3 +50,3 @@ type: _SimpleSchema.SimpleSchema.oneOf(String),

it('second level object', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: Object,

@@ -65,4 +65,4 @@ 'foo.aaa': {

});
const newSchema = schema.getObjectSchema('foo.bbb');
(0, _expect.default)(newSchema.mergedSchema()).toEqual({
var newSchema = schema.getObjectSchema('foo.bbb');
(0, _expect["default"])(newSchema.mergedSchema()).toEqual({
zzz: {

@@ -76,3 +76,3 @@ type: _SimpleSchema.SimpleSchema.oneOf(Number),

it('object in array', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: Object,

@@ -94,4 +94,4 @@ 'foo.aaa': {

});
const newSchema = schema.getObjectSchema('foo.aaa.$');
(0, _expect.default)(newSchema.mergedSchema()).toEqual({
var newSchema = schema.getObjectSchema('foo.aaa.$');
(0, _expect["default"])(newSchema.mergedSchema()).toEqual({
zzz: {

@@ -110,3 +110,3 @@ type: _SimpleSchema.SimpleSchema.oneOf(String),

it('subschema', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: new _SimpleSchema.SimpleSchema({

@@ -126,4 +126,4 @@ aaa: {

});
const newSchema = schema.getObjectSchema('foo');
(0, _expect.default)(newSchema.mergedSchema()).toEqual({
var newSchema = schema.getObjectSchema('foo');
(0, _expect["default"])(newSchema.mergedSchema()).toEqual({
aaa: {

@@ -130,0 +130,0 @@ type: _SimpleSchema.SimpleSchema.oneOf(String),

@@ -7,3 +7,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -14,96 +14,96 @@ /* eslint-disable func-names, prefer-arrow-callback */

it('string', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: String
});
const type = schema.getQuickTypeForKey('foo');
(0, _expect.default)(type).toBe('string');
var type = schema.getQuickTypeForKey('foo');
(0, _expect["default"])(type).toBe('string');
});
it('number', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: Number
});
const type = schema.getQuickTypeForKey('foo');
(0, _expect.default)(type).toBe('number');
var type = schema.getQuickTypeForKey('foo');
(0, _expect["default"])(type).toBe('number');
});
it('int', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: _SimpleSchema.SimpleSchema.Integer
});
const type = schema.getQuickTypeForKey('foo');
(0, _expect.default)(type).toBe('number');
var type = schema.getQuickTypeForKey('foo');
(0, _expect["default"])(type).toBe('number');
});
it('boolean', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: Boolean
});
const type = schema.getQuickTypeForKey('foo');
(0, _expect.default)(type).toBe('boolean');
var type = schema.getQuickTypeForKey('foo');
(0, _expect["default"])(type).toBe('boolean');
});
it('date', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: Date
});
const type = schema.getQuickTypeForKey('foo');
(0, _expect.default)(type).toBe('date');
var type = schema.getQuickTypeForKey('foo');
(0, _expect["default"])(type).toBe('date');
});
it('object', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: Object
});
const type = schema.getQuickTypeForKey('foo');
(0, _expect.default)(type).toBe('object');
var type = schema.getQuickTypeForKey('foo');
(0, _expect["default"])(type).toBe('object');
});
it('stringArray', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: [String]
});
const type = schema.getQuickTypeForKey('foo');
(0, _expect.default)(type).toBe('stringArray');
var type = schema.getQuickTypeForKey('foo');
(0, _expect["default"])(type).toBe('stringArray');
});
it('numberArray', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: [Number]
});
const type = schema.getQuickTypeForKey('foo');
(0, _expect.default)(type).toBe('numberArray');
var type = schema.getQuickTypeForKey('foo');
(0, _expect["default"])(type).toBe('numberArray');
});
it('int array', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: [_SimpleSchema.SimpleSchema.Integer]
});
const type = schema.getQuickTypeForKey('foo');
(0, _expect.default)(type).toBe('numberArray');
var type = schema.getQuickTypeForKey('foo');
(0, _expect["default"])(type).toBe('numberArray');
});
it('booleanArray', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: [Boolean]
});
const type = schema.getQuickTypeForKey('foo');
(0, _expect.default)(type).toBe('booleanArray');
var type = schema.getQuickTypeForKey('foo');
(0, _expect["default"])(type).toBe('booleanArray');
});
it('dateArray', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: [Date]
});
const type = schema.getQuickTypeForKey('foo');
(0, _expect.default)(type).toBe('dateArray');
var type = schema.getQuickTypeForKey('foo');
(0, _expect["default"])(type).toBe('dateArray');
});
it('objectArray', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: [Object]
});
const type = schema.getQuickTypeForKey('foo');
(0, _expect.default)(type).toBe('objectArray');
var type = schema.getQuickTypeForKey('foo');
(0, _expect["default"])(type).toBe('objectArray');
});
it('objectArray (subschema)', function () {
const subschema = new _SimpleSchema.SimpleSchema({
var subschema = new _SimpleSchema.SimpleSchema({
bar: String
});
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: [subschema]
});
const type = schema.getQuickTypeForKey('foo');
(0, _expect.default)(type).toBe('objectArray');
var type = schema.getQuickTypeForKey('foo');
(0, _expect["default"])(type).toBe('objectArray');
});
});
});

@@ -7,3 +7,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -13,3 +13,3 @@ /* eslint-disable func-names, prefer-arrow-callback */

it('inflection', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
minMaxNumber: {

@@ -25,7 +25,7 @@ type: _SimpleSchema.SimpleSchema.Integer

});
(0, _expect.default)(schema.label('minMaxNumber')).toEqual('Min max number');
(0, _expect.default)(schema.label('obj.someString')).toEqual('Some string');
(0, _expect["default"])(schema.label('minMaxNumber')).toEqual('Min max number');
(0, _expect["default"])(schema.label('obj.someString')).toEqual('Some string');
});
it('dynamic', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
minMaxNumber: {

@@ -41,10 +41,10 @@ type: _SimpleSchema.SimpleSchema.Integer

});
(0, _expect.default)(schema.label('obj.someString')).toEqual('Some string');
(0, _expect["default"])(schema.label('obj.someString')).toEqual('Some string');
schema.labels({
'obj.someString': 'A different label'
});
(0, _expect.default)(schema.label('obj.someString')).toEqual('A different label');
(0, _expect["default"])(schema.label('obj.someString')).toEqual('A different label');
});
it('callback', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
minMaxNumber: {

@@ -60,10 +60,12 @@ type: _SimpleSchema.SimpleSchema.Integer

});
(0, _expect.default)(schema.label('obj.someString')).toEqual('Some string');
(0, _expect["default"])(schema.label('obj.someString')).toEqual('Some string');
schema.labels({
'obj.someString': () => 'A callback label'
'obj.someString': function objSomeString() {
return 'A callback label';
}
});
(0, _expect.default)(schema.label('obj.someString')).toEqual('A callback label');
(0, _expect["default"])(schema.label('obj.someString')).toEqual('A callback label');
});
it('should allow apostrophes ("\'") in labels', () => {
const schema = new _SimpleSchema.SimpleSchema({
it('should allow apostrophes ("\'") in labels', function () {
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -74,4 +76,4 @@ type: String,

});
(0, _expect.default)(schema.label('foo')).toEqual('Manager/supervisor\'s name');
(0, _expect["default"])(schema.label('foo')).toEqual('Manager/supervisor\'s name');
});
});

@@ -13,3 +13,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -20,15 +20,15 @@ /* eslint-disable func-names, prefer-arrow-callback */

it('string', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxString: 'nottoolongnottoolong'
}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxString: 'toolongtoolongtoolong'
}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxStringArray: ['nottoolongnottoolong', 'nottoolongnottoolong']
}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxStringArray: ['toolongtoolongtoolong', 'toolongtoolongtoolong']
}).toEqual(2);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxStringArray: ['nottoolongnottoolong', 'nottoolongnottoolong', 'nottoolongnottoolong']

@@ -38,12 +38,12 @@ }).toEqual(1);

it('number', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxNumber: 20
}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxNumber: 21
}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxNumberCalculated: 20
}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxNumberCalculated: 21

@@ -53,12 +53,12 @@ }).toEqual(1);

it('date', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxDate: new Date(Date.UTC(2013, 11, 31))
}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxDate: new Date(Date.UTC(2014, 0, 1))
}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxDateCalculated: new Date(Date.UTC(2013, 11, 31))
}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxDateCalculated: new Date(Date.UTC(2014, 0, 1))

@@ -70,3 +70,3 @@ }).toEqual(1);

it('string', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -79,3 +79,3 @@ minMaxString: 'nottoolongnottoolong'

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -88,3 +88,3 @@ minMaxString: 'toolongtoolongtoolong'

}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -97,3 +97,3 @@ minMaxStringArray: ['nottoolongnottoolong', 'nottoolongnottoolong']

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -106,3 +106,3 @@ minMaxStringArray: ['toolongtoolongtoolong', 'toolongtoolongtoolong']

}).toEqual(2);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -117,3 +117,3 @@ minMaxStringArray: ['nottoolongnottoolong', 'nottoolongnottoolong', 'nottoolongnottoolong']

it('number', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -126,3 +126,3 @@ minMaxNumber: 20

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -135,3 +135,3 @@ minMaxNumber: 21

}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -144,3 +144,3 @@ minMaxNumberCalculated: 20

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -155,3 +155,3 @@ minMaxNumberCalculated: 21

it('date', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -164,3 +164,3 @@ minMaxDate: new Date(Date.UTC(2013, 11, 31))

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -173,3 +173,3 @@ minMaxDate: new Date(Date.UTC(2014, 0, 1))

}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -182,3 +182,3 @@ minMaxDateCalculated: new Date(Date.UTC(2013, 11, 31))

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -195,3 +195,3 @@ minMaxDateCalculated: new Date(Date.UTC(2014, 0, 1))

it('string', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -203,3 +203,3 @@ minMaxString: 'nottoolongnottoolong'

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -211,3 +211,3 @@ minMaxString: 'toolongtoolongtoolong'

}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -219,3 +219,3 @@ minMaxStringArray: ['nottoolongnottoolong', 'nottoolongnottoolong']

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -227,3 +227,3 @@ minMaxStringArray: ['toolongtoolongtoolong', 'toolongtoolongtoolong']

}).toEqual(2);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -237,3 +237,3 @@ minMaxStringArray: ['nottoolongnottoolong', 'nottoolongnottoolong', 'nottoolongnottoolong']

it('number', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -245,3 +245,3 @@ minMaxNumber: 20

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -253,3 +253,3 @@ minMaxNumber: 21

}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -261,3 +261,3 @@ minMaxNumberCalculated: 20

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -269,3 +269,3 @@ minMaxNumberCalculated: 21

}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -278,3 +278,3 @@ maxZero: 1

(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$inc: {

@@ -288,3 +288,3 @@ maxZero: 5

it('date', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -296,3 +296,3 @@ minMaxDate: new Date(Date.UTC(2013, 11, 31))

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -304,3 +304,3 @@ minMaxDate: new Date(Date.UTC(2014, 0, 1))

}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -312,3 +312,3 @@ minMaxDateCalculated: new Date(Date.UTC(2013, 11, 31))

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -324,3 +324,3 @@ minMaxDateCalculated: new Date(Date.UTC(2014, 0, 1))

it('valid', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.MAX_STRING, _friendsSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.MAX_STRING, _friendsSchema["default"], {
$push: {

@@ -337,3 +337,3 @@ friends: {

it('invalid', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.MAX_STRING, _friendsSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.MAX_STRING, _friendsSchema["default"], {
$push: {

@@ -352,3 +352,3 @@ friends: {

it('valid', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.MAX_STRING, _friendsSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.MAX_STRING, _friendsSchema["default"], {
$push: {

@@ -370,3 +370,3 @@ friends: {

it('invalid', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.MAX_STRING, _friendsSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.MAX_STRING, _friendsSchema["default"], {
$push: {

@@ -390,3 +390,3 @@ friends: {

it('valid', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.MAX_STRING, _friendsSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.MAX_STRING, _friendsSchema["default"], {
$addToSet: {

@@ -403,3 +403,3 @@ friends: {

it('invalid', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.MAX_STRING, _friendsSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.MAX_STRING, _friendsSchema["default"], {
$addToSet: {

@@ -418,3 +418,3 @@ friends: {

it('valid', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.MAX_STRING, _friendsSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.MAX_STRING, _friendsSchema["default"], {
$addToSet: {

@@ -436,3 +436,3 @@ friends: {

it('invalid', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.MAX_STRING, _friendsSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.MAX_STRING, _friendsSchema["default"], {
$addToSet: {

@@ -439,0 +439,0 @@ friends: {

@@ -7,3 +7,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -14,11 +14,11 @@ /* eslint-disable func-names, prefer-arrow-callback */

it('required', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: String
});
const context = schema.newContext();
var context = schema.newContext();
context.validate({});
(0, _expect.default)(context.keyErrorMessage('foo')).toBe('Foo is required');
(0, _expect["default"])(context.keyErrorMessage('foo')).toBe('Foo is required');
});
it('minString', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -29,10 +29,10 @@ type: String,

});
const context = schema.newContext();
var context = schema.newContext();
context.validate({
foo: 'a'
});
(0, _expect.default)(context.keyErrorMessage('foo')).toBe('Foo must be at least 2 characters');
(0, _expect["default"])(context.keyErrorMessage('foo')).toBe('Foo must be at least 2 characters');
});
it('maxString', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -43,10 +43,10 @@ type: String,

});
const context = schema.newContext();
var context = schema.newContext();
context.validate({
foo: 'abc'
});
(0, _expect.default)(context.keyErrorMessage('foo')).toBe('Foo cannot exceed 2 characters');
(0, _expect["default"])(context.keyErrorMessage('foo')).toBe('Foo cannot exceed 2 characters');
});
it('minNumber', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -57,10 +57,10 @@ type: Number,

});
const context = schema.newContext();
var context = schema.newContext();
context.validate({
foo: 1.5
});
(0, _expect.default)(context.keyErrorMessage('foo')).toBe('Foo must be at least 2');
(0, _expect["default"])(context.keyErrorMessage('foo')).toBe('Foo must be at least 2');
});
it('maxNumber', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -71,10 +71,10 @@ type: Number,

});
const context = schema.newContext();
var context = schema.newContext();
context.validate({
foo: 2.5
});
(0, _expect.default)(context.keyErrorMessage('foo')).toBe('Foo cannot exceed 2');
(0, _expect["default"])(context.keyErrorMessage('foo')).toBe('Foo cannot exceed 2');
});
it('minNumberExclusive', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -86,10 +86,10 @@ type: Number,

});
const context = schema.newContext();
var context = schema.newContext();
context.validate({
foo: 2
});
(0, _expect.default)(context.keyErrorMessage('foo')).toBe('Foo must be greater than 2');
(0, _expect["default"])(context.keyErrorMessage('foo')).toBe('Foo must be greater than 2');
});
it('maxNumberExclusive', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -101,10 +101,10 @@ type: Number,

});
const context = schema.newContext();
var context = schema.newContext();
context.validate({
foo: 2
});
(0, _expect.default)(context.keyErrorMessage('foo')).toBe('Foo must be less than 2');
(0, _expect["default"])(context.keyErrorMessage('foo')).toBe('Foo must be less than 2');
});
it('minDate', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -115,10 +115,10 @@ type: Date,

});
const context = schema.newContext();
var context = schema.newContext();
context.validate({
foo: new Date(Date.UTC(2015, 10, 15, 0, 0, 0, 0))
});
(0, _expect.default)(context.keyErrorMessage('foo')).toBe('Foo must be on or after 2015-12-15');
(0, _expect["default"])(context.keyErrorMessage('foo')).toBe('Foo must be on or after 2015-12-15');
});
it('maxDate', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -129,10 +129,10 @@ type: Date,

});
const context = schema.newContext();
var context = schema.newContext();
context.validate({
foo: new Date(Date.UTC(2016, 1, 15, 0, 0, 0, 0))
});
(0, _expect.default)(context.keyErrorMessage('foo')).toBe('Foo cannot be after 2015-12-15');
(0, _expect["default"])(context.keyErrorMessage('foo')).toBe('Foo cannot be after 2015-12-15');
});
it('badDate', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -142,10 +142,10 @@ type: Date

});
const context = schema.newContext();
var context = schema.newContext();
context.validate({
foo: new Date('invalid')
});
(0, _expect.default)(context.keyErrorMessage('foo')).toBe('Foo is not a valid date');
(0, _expect["default"])(context.keyErrorMessage('foo')).toBe('Foo is not a valid date');
});
it('minCount', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -157,10 +157,10 @@ type: Array,

});
const context = schema.newContext();
var context = schema.newContext();
context.validate({
foo: [1]
});
(0, _expect.default)(context.keyErrorMessage('foo')).toBe('You must specify at least 2 values');
(0, _expect["default"])(context.keyErrorMessage('foo')).toBe('You must specify at least 2 values');
});
it('maxCount', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -172,20 +172,20 @@ type: Array,

});
const context = schema.newContext();
var context = schema.newContext();
context.validate({
foo: [1, 2, 3]
});
(0, _expect.default)(context.keyErrorMessage('foo')).toBe('You cannot specify more than 2 values');
(0, _expect["default"])(context.keyErrorMessage('foo')).toBe('You cannot specify more than 2 values');
});
it('noDecimal', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: _SimpleSchema.SimpleSchema.Integer
});
const context = schema.newContext();
var context = schema.newContext();
context.validate({
foo: 1.5
});
(0, _expect.default)(context.keyErrorMessage('foo')).toBe('Foo must be an integer');
(0, _expect["default"])(context.keyErrorMessage('foo')).toBe('Foo must be an integer');
});
it('notAllowed', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -196,20 +196,20 @@ type: String,

});
const context = schema.newContext();
var context = schema.newContext();
context.validate({
foo: 'd'
});
(0, _expect.default)(context.keyErrorMessage('foo')).toBe('d is not an allowed value');
(0, _expect["default"])(context.keyErrorMessage('foo')).toBe('d is not an allowed value');
});
it('expectedType', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: String
});
const context = schema.newContext();
var context = schema.newContext();
context.validate({
foo: 1
});
(0, _expect.default)(context.keyErrorMessage('foo')).toBe('Foo must be of type String');
(0, _expect["default"])(context.keyErrorMessage('foo')).toBe('Foo must be of type String');
});
it('regEx built in', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -220,10 +220,10 @@ type: String,

});
const context = schema.newContext();
var context = schema.newContext();
context.validate({
foo: 'abc'
});
(0, _expect.default)(context.keyErrorMessage('foo')).toBe('Foo must be a valid email address');
(0, _expect["default"])(context.keyErrorMessage('foo')).toBe('Foo must be a valid email address');
});
it('regEx other', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -234,21 +234,21 @@ type: String,

});
const context = schema.newContext();
var context = schema.newContext();
context.validate({
foo: 'abc'
});
(0, _expect.default)(context.keyErrorMessage('foo')).toBe('Foo failed regular expression validation');
(0, _expect["default"])(context.keyErrorMessage('foo')).toBe('Foo failed regular expression validation');
});
describe('keyNotInSchema', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: String
});
it('normal', function () {
const context = schema.newContext();
var context = schema.newContext();
context.validate({
bar: 1
});
(0, _expect.default)(context.keyErrorMessage('bar')).toBe('bar is not allowed by the schema');
(0, _expect["default"])(context.keyErrorMessage('bar')).toBe('bar is not allowed by the schema');
});
it('$set', function () {
const context = schema.newContext();
var context = schema.newContext();
context.validate({

@@ -261,6 +261,6 @@ $set: {

});
(0, _expect.default)(context.keyErrorMessage('bar')).toBe('bar is not allowed by the schema');
(0, _expect["default"])(context.keyErrorMessage('bar')).toBe('bar is not allowed by the schema');
});
it('$unset does not complain', function () {
const context = schema.newContext();
var context = schema.newContext();
context.validate({

@@ -273,7 +273,7 @@ $unset: {

});
(0, _expect.default)(context.isValid()).toBe(true);
(0, _expect["default"])(context.isValid()).toBe(true);
});
});
it('should allow labels with apostrophes ("\'") in messages', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -284,9 +284,9 @@ type: String,

});
const context = schema.newContext();
var context = schema.newContext();
context.validate({});
(0, _expect.default)(context.keyErrorMessage('foo')).toBe('Manager/supervisor\'s name is required');
(0, _expect["default"])(context.keyErrorMessage('foo')).toBe('Manager/supervisor\'s name is required');
});
});
describe('multipleSchema', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: String

@@ -301,3 +301,3 @@ });

});
const schema2 = new _SimpleSchema.SimpleSchema({
var schema2 = new _SimpleSchema.SimpleSchema({
foo: String,

@@ -314,7 +314,7 @@ bar: Number

it('should keep message boxes separate between objects', function () {
const context = schema.newContext();
var context = schema.newContext();
context.validate({});
(0, _expect.default)(context.keyErrorMessage('foo')).toBe('Your foo is required mate');
(0, _expect["default"])(context.keyErrorMessage('foo')).toBe('Your foo is required mate');
});
});
});

@@ -7,3 +7,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -14,18 +14,18 @@ /* eslint-disable func-names, prefer-arrow-callback */

it('string', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxString: 'longenough'
}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxString: 'short'
}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxString: ''
}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxStringArray: ['longenough', 'longenough']
}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxStringArray: ['longenough', 'short']
}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxStringArray: ['short', 'short']

@@ -35,27 +35,27 @@ }).toEqual(2);

it('number', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxNumberExclusive: 20
}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxNumberExclusive: 10
}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxNumberInclusive: 20
}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxNumberInclusive: 10
}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxNumber: 10
}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxNumber: 9
}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxNumberCalculated: 10
}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxNumberCalculated: 9
}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minZero: -1

@@ -65,12 +65,12 @@ }).toEqual(1);

it('date', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxDate: new Date(Date.UTC(2013, 0, 1))
}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxDate: new Date(Date.UTC(2012, 11, 31))
}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxDateCalculated: new Date(Date.UTC(2013, 0, 1))
}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
minMaxDateCalculated: new Date(Date.UTC(2012, 11, 31))

@@ -82,3 +82,3 @@ }).toEqual(1);

it('string', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -91,3 +91,3 @@ minMaxString: 'longenough'

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -100,3 +100,3 @@ minMaxString: 'short'

}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -109,3 +109,3 @@ minMaxStringArray: ['longenough', 'longenough']

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -118,3 +118,3 @@ minMaxStringArray: ['longenough', 'short']

}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -129,3 +129,3 @@ minMaxStringArray: ['short', 'short']

it('number', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -138,3 +138,3 @@ minMaxNumber: 10

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -147,3 +147,3 @@ minMaxNumber: 9

}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -156,3 +156,3 @@ minMaxNumberCalculated: 10

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -165,3 +165,3 @@ minMaxNumberCalculated: 9

}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -176,3 +176,3 @@ minZero: -1

it('date', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -185,3 +185,3 @@ minMaxDate: new Date(Date.UTC(2013, 0, 1))

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -194,3 +194,3 @@ minMaxDate: new Date(Date.UTC(2012, 11, 31))

}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -203,3 +203,3 @@ minMaxDateCalculated: new Date(Date.UTC(2013, 0, 1))

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$setOnInsert: {

@@ -216,3 +216,3 @@ minMaxDateCalculated: new Date(Date.UTC(2012, 11, 31))

it('string', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -224,3 +224,3 @@ minMaxString: 'longenough'

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -232,3 +232,3 @@ minMaxString: 'short'

}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -240,3 +240,3 @@ minMaxStringArray: ['longenough', 'longenough']

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -248,3 +248,3 @@ minMaxStringArray: ['longenough', 'short']

}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -258,3 +258,3 @@ minMaxStringArray: ['short', 'short']

it('number', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -266,3 +266,3 @@ minMaxNumber: 10

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -274,3 +274,3 @@ minMaxNumber: 9

}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -282,3 +282,3 @@ minMaxNumberCalculated: 10

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -290,3 +290,3 @@ minMaxNumberCalculated: 9

}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -299,3 +299,3 @@ minZero: -1

(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$inc: {

@@ -309,3 +309,3 @@ minZero: -5

it('date', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -317,3 +317,3 @@ minMaxDate: new Date(Date.UTC(2013, 0, 1))

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -325,3 +325,3 @@ minMaxDate: new Date(Date.UTC(2012, 11, 31))

}).toEqual(1);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -333,3 +333,3 @@ minMaxDateCalculated: new Date(Date.UTC(2013, 0, 1))

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$set: {

@@ -336,0 +336,0 @@ minMaxDateCalculated: new Date(Date.UTC(2012, 11, 31))

@@ -7,3 +7,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -13,7 +13,7 @@ /* eslint-disable func-names, prefer-arrow-callback */

it('ensures array count is at least the minimum', function () {
(0, _expectErrorLength.default)(_friendsSchema.default, {
(0, _expectErrorLength["default"])(_friendsSchema["default"], {
friends: [],
enemies: []
}).toEqual(1);
(0, _expectErrorLength.default)(_friendsSchema.default, {
(0, _expectErrorLength["default"])(_friendsSchema["default"], {
$set: {

@@ -25,3 +25,3 @@ friends: []

}).toEqual(1);
(0, _expectErrorLength.default)(_friendsSchema.default, {
(0, _expectErrorLength["default"])(_friendsSchema["default"], {
$setOnInsert: {

@@ -28,0 +28,0 @@ friends: [],

@@ -7,3 +7,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -13,3 +13,3 @@ /* eslint-disable func-names, prefer-arrow-callback */

it('omit', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -31,11 +31,11 @@ type: Object

});
let newSchema = schema.omit('foo');
(0, _expect.default)(Object.keys(newSchema.schema())).toEqual(['fooArray', 'fooArray.$', 'fooArray.$.bar']);
var newSchema = schema.omit('foo');
(0, _expect["default"])(Object.keys(newSchema.schema())).toEqual(['fooArray', 'fooArray.$', 'fooArray.$.bar']);
newSchema = schema.omit('fooArray');
(0, _expect.default)(Object.keys(newSchema.schema())).toEqual(['foo', 'foo.bar']);
(0, _expect["default"])(Object.keys(newSchema.schema())).toEqual(['foo', 'foo.bar']);
newSchema = schema.omit('foo', 'fooArray');
(0, _expect.default)(Object.keys(newSchema.schema())).toEqual([]);
(0, _expect["default"])(Object.keys(newSchema.schema())).toEqual([]);
newSchema = schema.omit('blah');
(0, _expect.default)(Object.keys(newSchema.schema())).toEqual(['foo', 'foo.bar', 'fooArray', 'fooArray.$', 'fooArray.$.bar']);
(0, _expect["default"])(Object.keys(newSchema.schema())).toEqual(['foo', 'foo.bar', 'fooArray', 'fooArray.$', 'fooArray.$.bar']);
});
});

@@ -7,3 +7,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -14,51 +14,51 @@ /* eslint-disable func-names, prefer-arrow-callback */

it('allows either type', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: _SimpleSchema.SimpleSchema.oneOf(String, Number, Date)
});
const test1 = {
var test1 = {
foo: 1
};
(0, _expect.default)(function test1func() {
(0, _expect["default"])(function test1func() {
schema.validate(test1);
}).toNotThrow();
(0, _expect.default)(test1.foo).toBeA('number');
const test2 = {
(0, _expect["default"])(test1.foo).toBeA('number');
var test2 = {
foo: 'bar'
};
(0, _expect.default)(function test2func() {
(0, _expect["default"])(function test2func() {
schema.validate(test2);
}).toNotThrow();
(0, _expect.default)(test2.foo).toBeA('string');
const test3 = {
(0, _expect["default"])(test2.foo).toBeA('string');
var test3 = {
foo: new Date()
};
(0, _expect.default)(function test2func() {
(0, _expect["default"])(function test2func() {
schema.validate(test3);
}).toNotThrow();
(0, _expect.default)(test3.foo instanceof Date).toBe(true);
const test4 = {
(0, _expect["default"])(test3.foo instanceof Date).toBe(true);
var test4 = {
foo: false
};
(0, _expect.default)(function test3func() {
(0, _expect["default"])(function test3func() {
schema.validate(test4);
}).toThrow();
(0, _expect.default)(test4.foo).toBeA('boolean');
(0, _expect["default"])(test4.foo).toBeA('boolean');
});
it.skip('allows either type including schemas', function () {
const schemaOne = new _SimpleSchema.SimpleSchema({
var schemaOne = new _SimpleSchema.SimpleSchema({
itemRef: String,
partNo: String
});
const schemaTwo = new _SimpleSchema.SimpleSchema({
var schemaTwo = new _SimpleSchema.SimpleSchema({
anotherIdentifier: String,
partNo: String
});
const combinedSchema = new _SimpleSchema.SimpleSchema({
var combinedSchema = new _SimpleSchema.SimpleSchema({
item: _SimpleSchema.SimpleSchema.oneOf(String, schemaOne, schemaTwo)
});
let isValid = combinedSchema.namedContext().validate({
var isValid = combinedSchema.namedContext().validate({
item: 'foo'
});
console.log(combinedSchema.namedContext().validationErrors());
(0, _expect.default)(isValid).toBe(true);
(0, _expect["default"])(isValid).toBe(true);
isValid = combinedSchema.namedContext().validate({

@@ -71,3 +71,3 @@ item: {

console.log(combinedSchema.namedContext().validationErrors());
(0, _expect.default)(isValid).toBe(true);
(0, _expect["default"])(isValid).toBe(true);
isValid = combinedSchema.namedContext().validate({

@@ -80,6 +80,6 @@ item: {

console.log(combinedSchema.namedContext().validationErrors());
(0, _expect.default)(isValid).toBe(true);
(0, _expect["default"])(isValid).toBe(true);
});
it('is valid as long as one min value is met', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: _SimpleSchema.SimpleSchema.oneOf({

@@ -93,3 +93,3 @@ type: _SimpleSchema.SimpleSchema.Integer,

});
(0, _expect.default)(function () {
(0, _expect["default"])(function () {
schema.validate({

@@ -101,3 +101,3 @@ foo: 7

it('is invalid if neither min value is met', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: _SimpleSchema.SimpleSchema.oneOf({

@@ -111,3 +111,3 @@ type: _SimpleSchema.SimpleSchema.Integer,

});
(0, _expect.default)(function () {
(0, _expect["default"])(function () {
schema.validate({

@@ -114,0 +114,0 @@ foo: 3

@@ -7,3 +7,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -13,3 +13,3 @@ /* eslint-disable func-names, prefer-arrow-callback */

it('pick', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -31,13 +31,13 @@ type: Object

});
let newSchema = schema.pick('foo');
(0, _expect.default)(Object.keys(newSchema.schema())).toEqual(['foo', 'foo.bar']);
var newSchema = schema.pick('foo');
(0, _expect["default"])(Object.keys(newSchema.schema())).toEqual(['foo', 'foo.bar']);
newSchema = schema.pick('fooArray');
(0, _expect.default)(Object.keys(newSchema.schema())).toEqual(['fooArray', 'fooArray.$', 'fooArray.$.bar']);
(0, _expect["default"])(Object.keys(newSchema.schema())).toEqual(['fooArray', 'fooArray.$', 'fooArray.$.bar']);
newSchema = schema.pick('foo', 'fooArray');
(0, _expect.default)(Object.keys(newSchema.schema())).toEqual(['foo', 'foo.bar', 'fooArray', 'fooArray.$', 'fooArray.$.bar']);
(0, _expect["default"])(Object.keys(newSchema.schema())).toEqual(['foo', 'foo.bar', 'fooArray', 'fooArray.$', 'fooArray.$.bar']);
newSchema = schema.pick('blah');
(0, _expect.default)(Object.keys(newSchema.schema())).toEqual([]);
(0, _expect["default"])(Object.keys(newSchema.schema())).toEqual([]);
});
it('error when you do not pick the parent', () => {
const schema = new _SimpleSchema.SimpleSchema({
it('error when you do not pick the parent', function () {
var schema = new _SimpleSchema.SimpleSchema({
level1: {

@@ -50,3 +50,3 @@ type: Object

});
(0, _expect.default)(() => {
(0, _expect["default"])(function () {
schema.pick('level1.level2');

@@ -53,0 +53,0 @@ }).toThrow('"level1.level2" is in the schema but "level1" is not');

@@ -7,3 +7,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -14,3 +14,3 @@ /* eslint-disable func-names, prefer-arrow-callback */

// Make sure no regEx errors for optional
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -22,7 +22,7 @@ type: String,

});
(0, _expect.default)(schema.newContext().validate({})).toEqual(true);
(0, _expect.default)(schema.newContext().validate({
(0, _expect["default"])(schema.newContext().validate({})).toEqual(true);
(0, _expect["default"])(schema.newContext().validate({
foo: null
})).toEqual(true);
(0, _expect.default)(schema.newContext().validate({
(0, _expect["default"])(schema.newContext().validate({
foo: ''

@@ -32,3 +32,3 @@ })).toEqual(false);

it('Built-In RegEx and Messages', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
email: {

@@ -80,51 +80,51 @@ type: String,

});
const c1 = schema.newContext();
var c1 = schema.newContext();
c1.validate({
email: 'foo'
});
(0, _expect.default)(c1.validationErrors().length).toEqual(1);
(0, _expect.default)(c1.keyErrorMessage('email')).toEqual('Email must be a valid email address');
(0, _expect["default"])(c1.validationErrors().length).toEqual(1);
(0, _expect["default"])(c1.keyErrorMessage('email')).toEqual('Email must be a valid email address');
c1.validate({
emailWithTLD: 'foo'
});
(0, _expect.default)(c1.validationErrors().length).toEqual(1);
(0, _expect.default)(c1.keyErrorMessage('emailWithTLD')).toEqual('Email with tld must be a valid email address');
(0, _expect["default"])(c1.validationErrors().length).toEqual(1);
(0, _expect["default"])(c1.keyErrorMessage('emailWithTLD')).toEqual('Email with tld must be a valid email address');
c1.validate({
domain: 'foo'
});
(0, _expect.default)(c1.validationErrors().length).toEqual(1);
(0, _expect.default)(c1.keyErrorMessage('domain')).toEqual('Domain must be a valid domain');
(0, _expect["default"])(c1.validationErrors().length).toEqual(1);
(0, _expect["default"])(c1.keyErrorMessage('domain')).toEqual('Domain must be a valid domain');
c1.validate({
weakDomain: '///jioh779&%'
});
(0, _expect.default)(c1.validationErrors().length).toEqual(1);
(0, _expect.default)(c1.keyErrorMessage('weakDomain')).toEqual('Weak domain must be a valid domain');
(0, _expect["default"])(c1.validationErrors().length).toEqual(1);
(0, _expect["default"])(c1.keyErrorMessage('weakDomain')).toEqual('Weak domain must be a valid domain');
c1.validate({
ip: 'foo'
});
(0, _expect.default)(c1.validationErrors().length).toEqual(1);
(0, _expect.default)(c1.keyErrorMessage('ip')).toEqual('Ip must be a valid IPv4 or IPv6 address');
(0, _expect["default"])(c1.validationErrors().length).toEqual(1);
(0, _expect["default"])(c1.keyErrorMessage('ip')).toEqual('Ip must be a valid IPv4 or IPv6 address');
c1.validate({
ip4: 'foo'
});
(0, _expect.default)(c1.validationErrors().length).toEqual(1);
(0, _expect.default)(c1.keyErrorMessage('ip4')).toEqual('Ip4 must be a valid IPv4 address');
(0, _expect["default"])(c1.validationErrors().length).toEqual(1);
(0, _expect["default"])(c1.keyErrorMessage('ip4')).toEqual('Ip4 must be a valid IPv4 address');
c1.validate({
ip6: 'foo'
});
(0, _expect.default)(c1.validationErrors().length).toEqual(1);
(0, _expect.default)(c1.keyErrorMessage('ip6')).toEqual('Ip6 must be a valid IPv6 address');
(0, _expect["default"])(c1.validationErrors().length).toEqual(1);
(0, _expect["default"])(c1.keyErrorMessage('ip6')).toEqual('Ip6 must be a valid IPv6 address');
c1.validate({
url: 'foo'
});
(0, _expect.default)(c1.validationErrors().length).toEqual(1);
(0, _expect.default)(c1.keyErrorMessage('url')).toEqual('Url must be a valid URL');
(0, _expect["default"])(c1.validationErrors().length).toEqual(1);
(0, _expect["default"])(c1.keyErrorMessage('url')).toEqual('Url must be a valid URL');
c1.validate({
id: '%#$%'
});
(0, _expect.default)(c1.validationErrors().length).toEqual(1);
(0, _expect.default)(c1.keyErrorMessage('id')).toEqual('ID must be a valid alphanumeric ID');
(0, _expect["default"])(c1.validationErrors().length).toEqual(1);
(0, _expect["default"])(c1.keyErrorMessage('id')).toEqual('ID must be a valid alphanumeric ID');
});
it('Optional regEx in subobject', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -140,8 +140,8 @@ type: Object,

});
const context = schema.namedContext();
(0, _expect.default)(context.validate({})).toEqual(true);
(0, _expect.default)(context.validate({
var context = schema.namedContext();
(0, _expect["default"])(context.validate({})).toEqual(true);
(0, _expect["default"])(context.validate({
foo: {}
})).toEqual(true);
(0, _expect.default)(context.validate({
(0, _expect["default"])(context.validate({
foo: {

@@ -151,3 +151,3 @@ url: null

})).toEqual(true);
(0, _expect.default)(context.validate({
(0, _expect["default"])(context.validate({
$set: {

@@ -159,3 +159,3 @@ foo: {}

})).toEqual(true);
(0, _expect.default)(context.validate({
(0, _expect["default"])(context.validate({
$set: {

@@ -167,3 +167,3 @@ 'foo.url': null

})).toEqual(true);
(0, _expect.default)(context.validate({
(0, _expect["default"])(context.validate({
$unset: {

@@ -177,10 +177,10 @@ 'foo.url': ''

it('SimpleSchema.RegEx.Email', function () {
const expr = _SimpleSchema.SimpleSchema.RegEx.Email;
var expr = _SimpleSchema.SimpleSchema.RegEx.Email;
function isTrue(s) {
(0, _expect.default)(expr.test(s)).toBe(true);
(0, _expect["default"])(expr.test(s)).toBe(true);
}
function isFalse(s) {
(0, _expect.default)(expr.test(s)).toBe(false);
(0, _expect["default"])(expr.test(s)).toBe(false);
}

@@ -199,10 +199,10 @@

it('SimpleSchema.RegEx.EmailWithTLD', function () {
const expr = _SimpleSchema.SimpleSchema.RegEx.EmailWithTLD;
var expr = _SimpleSchema.SimpleSchema.RegEx.EmailWithTLD;
function isTrue(s) {
(0, _expect.default)(expr.test(s)).toBe(true);
(0, _expect["default"])(expr.test(s)).toBe(true);
}
function isFalse(s) {
(0, _expect.default)(expr.test(s)).toBe(false);
(0, _expect["default"])(expr.test(s)).toBe(false);
}

@@ -221,10 +221,10 @@

it('SimpleSchema.RegEx.Domain', function () {
const expr = _SimpleSchema.SimpleSchema.RegEx.Domain;
var expr = _SimpleSchema.SimpleSchema.RegEx.Domain;
function isTrue(s) {
(0, _expect.default)(expr.test(s)).toBe(true);
(0, _expect["default"])(expr.test(s)).toBe(true);
}
function isFalse(s) {
(0, _expect.default)(expr.test(s)).toBe(false);
(0, _expect["default"])(expr.test(s)).toBe(false);
}

@@ -238,6 +238,6 @@

it('SimpleSchema.RegEx.WeakDomain', function () {
const expr = _SimpleSchema.SimpleSchema.RegEx.WeakDomain;
var expr = _SimpleSchema.SimpleSchema.RegEx.WeakDomain;
function isTrue(s) {
(0, _expect.default)(expr.test(s)).toBe(true);
(0, _expect["default"])(expr.test(s)).toBe(true);
}

@@ -251,10 +251,10 @@

it('SimpleSchema.RegEx.IP', function () {
const expr = _SimpleSchema.SimpleSchema.RegEx.IP;
var expr = _SimpleSchema.SimpleSchema.RegEx.IP;
function isTrue(s) {
(0, _expect.default)(expr.test(s)).toBe(true);
(0, _expect["default"])(expr.test(s)).toBe(true);
}
function isFalse(s) {
(0, _expect.default)(expr.test(s)).toBe(false);
(0, _expect["default"])(expr.test(s)).toBe(false);
}

@@ -273,10 +273,10 @@

it('SimpleSchema.RegEx.IPv4', function () {
const expr = _SimpleSchema.SimpleSchema.RegEx.IPv4;
var expr = _SimpleSchema.SimpleSchema.RegEx.IPv4;
function isTrue(s) {
(0, _expect.default)(expr.test(s)).toBe(true);
(0, _expect["default"])(expr.test(s)).toBe(true);
}
function isFalse(s) {
(0, _expect.default)(expr.test(s)).toBe(false);
(0, _expect["default"])(expr.test(s)).toBe(false);
}

@@ -295,10 +295,10 @@

it('SimpleSchema.RegEx.IPv6', function () {
const expr = _SimpleSchema.SimpleSchema.RegEx.IPv6;
var expr = _SimpleSchema.SimpleSchema.RegEx.IPv6;
function isTrue(s) {
(0, _expect.default)(expr.test(s)).toBe(true);
(0, _expect["default"])(expr.test(s)).toBe(true);
}
function isFalse(s) {
(0, _expect.default)(expr.test(s)).toBe(false);
(0, _expect["default"])(expr.test(s)).toBe(false);
}

@@ -305,0 +305,0 @@

@@ -17,3 +17,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -24,3 +24,3 @@ /* eslint-disable func-names, prefer-arrow-callback */

it('valid', function () {
(0, _expectValid.default)(_requiredSchema.default, {
(0, _expectValid["default"])(_requiredSchema["default"], {
requiredString: 'test',

@@ -39,3 +39,3 @@ requiredBoolean: true,

});
(0, _expectValid.default)(_requiredSchema.default, {
(0, _expectValid["default"])(_requiredSchema["default"], {
requiredString: 'test',

@@ -53,4 +53,4 @@ requiredBoolean: true,

it('invalid', function () {
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {}).toBe(8);
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {}).toBe(8);
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
requiredString: null,

@@ -67,3 +67,3 @@ requiredBoolean: null,

}).toBe(9);
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
requiredString: null,

@@ -79,3 +79,3 @@ requiredBoolean: null,

(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
requiredString: null,

@@ -91,3 +91,3 @@ requiredBoolean: null,

(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
requiredString: null,

@@ -101,3 +101,3 @@ requiredBoolean: null,

}).toBe(8);
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
requiredString: undefined,

@@ -114,3 +114,3 @@ requiredBoolean: undefined,

}).toBe(9);
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
requiredString: '',

@@ -127,3 +127,3 @@ requiredBoolean: null,

}).toBe(7);
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
requiredString: ' ',

@@ -141,3 +141,3 @@ requiredBoolean: null,

(0, _expectRequiredErrorLength.default)(_friendsSchema.default, {
(0, _expectRequiredErrorLength["default"])(_friendsSchema["default"], {
friends: [{

@@ -151,3 +151,3 @@ name: 'Bob'

it('requiredByDefault false', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: String

@@ -157,6 +157,6 @@ }, {

});
(0, _expectRequiredErrorLength.default)(schema, {}).toBe(0);
(0, _expectRequiredErrorLength["default"])(schema, {}).toBe(0);
});
it('required option', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -169,7 +169,7 @@ type: String,

});
(0, _expectRequiredErrorLength.default)(schema, {}).toBe(1);
(0, _expectRequiredErrorLength["default"])(schema, {}).toBe(1);
});
describe('modifier with $set', function () {
it('valid upsert', function () {
(0, _expectValid.default)(_requiredSchema.default, {
(0, _expectValid["default"])(_requiredSchema["default"], {
$set: {

@@ -193,3 +193,3 @@ requiredString: 'test',

});
(0, _expectValid.default)(_requiredSchema.default, {
(0, _expectValid["default"])(_requiredSchema["default"], {
$set: {

@@ -211,3 +211,3 @@ requiredString: 'test',

});
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
name: {

@@ -223,3 +223,3 @@ type: String

});
(0, _expectValid.default)(schema, {
(0, _expectValid["default"])(schema, {
$set: {

@@ -233,3 +233,3 @@ name: 'name'

it('invalid upsert', function () {
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$set: {}

@@ -241,3 +241,3 @@ }, {

(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$set: {

@@ -253,3 +253,3 @@ requiredEmail: null,

}).toBe(9);
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$set: {

@@ -269,3 +269,3 @@ requiredString: null,

}).toBe(9);
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$set: {

@@ -285,3 +285,3 @@ requiredString: undefined,

}).toBe(9);
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$set: {

@@ -301,3 +301,3 @@ requiredString: '',

}).toBe(7);
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$set: {

@@ -320,3 +320,3 @@ requiredString: ' ',

// Would not cause DB changes, so should not be an error
(0, _expectValid.default)(_requiredSchema.default, {
(0, _expectValid["default"])(_requiredSchema["default"], {
$set: {}

@@ -326,3 +326,3 @@ }, {

});
(0, _expectValid.default)(_requiredSchema.default, {
(0, _expectValid["default"])(_requiredSchema["default"], {
$set: {

@@ -341,3 +341,3 @@ requiredString: 'test',

});
(0, _expectValid.default)(_requiredSchema.default, {
(0, _expectValid["default"])(_requiredSchema["default"], {
$set: {

@@ -359,3 +359,3 @@ requiredString: 'test',

(0, _expectValid.default)(_friendsSchema.default, {
(0, _expectValid["default"])(_friendsSchema["default"], {
$set: {

@@ -369,3 +369,3 @@ enemies: [{

});
(0, _expectValid.default)(_friendsSchema.default, {
(0, _expectValid["default"])(_friendsSchema["default"], {
$set: {

@@ -377,3 +377,3 @@ 'friends.1.name': 'Bob'

});
(0, _expectValid.default)(_friendsSchema.default, {
(0, _expectValid["default"])(_friendsSchema["default"], {
$set: {

@@ -388,3 +388,3 @@ friends: [{

});
(0, _expectValid.default)(_friendsSchema.default, {
(0, _expectValid["default"])(_friendsSchema["default"], {
$set: {

@@ -402,3 +402,3 @@ enemies: [{

// MongoDB will set the props to `undefined`
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$set: {

@@ -417,3 +417,3 @@ requiredString: undefined,

}).toBe(9);
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$set: {

@@ -432,3 +432,3 @@ requiredString: null,

}).toBe(9);
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$set: {

@@ -447,3 +447,3 @@ requiredString: '',

}).toBe(7);
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$set: {

@@ -463,3 +463,3 @@ requiredString: ' ',

(0, _expectRequiredErrorLength.default)(_friendsSchema.default, {
(0, _expectRequiredErrorLength["default"])(_friendsSchema["default"], {
$set: {

@@ -472,3 +472,3 @@ enemies: [{}]

(0, _expectRequiredErrorLength.default)(_friendsSchema.default, {
(0, _expectRequiredErrorLength["default"])(_friendsSchema["default"], {
$set: {

@@ -481,3 +481,3 @@ 'friends.1.name': null

(0, _expectRequiredErrorLength.default)(_friendsSchema.default, {
(0, _expectRequiredErrorLength["default"])(_friendsSchema["default"], {
$set: {

@@ -491,3 +491,3 @@ friends: [{

}).toBe(1);
(0, _expectRequiredErrorLength.default)(_friendsSchema.default, {
(0, _expectRequiredErrorLength["default"])(_friendsSchema["default"], {
$set: {

@@ -502,3 +502,3 @@ enemies: [{

}).toBe(2);
(0, _expectRequiredErrorLength.default)(_friendsSchema.default, {
(0, _expectRequiredErrorLength["default"])(_friendsSchema["default"], {
$set: {

@@ -513,3 +513,3 @@ enemies: [{

}).toBe(4);
(0, _expectRequiredErrorLength.default)(_friendsSchema.default, {
(0, _expectRequiredErrorLength["default"])(_friendsSchema["default"], {
$set: {

@@ -530,3 +530,3 @@ enemies: [{

it('valid upsert', function () {
(0, _expectValid.default)(_requiredSchema.default, {
(0, _expectValid["default"])(_requiredSchema["default"], {
$setOnInsert: {

@@ -550,3 +550,3 @@ requiredString: 'test',

});
(0, _expectValid.default)(_requiredSchema.default, {
(0, _expectValid["default"])(_requiredSchema["default"], {
$setOnInsert: {

@@ -570,3 +570,3 @@ requiredString: 'test',

it('invalid upsert', function () {
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$setOnInsert: {}

@@ -577,3 +577,3 @@ }, {

}).toBe(8);
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$setOnInsert: {

@@ -593,3 +593,3 @@ requiredString: null,

}).toBe(9);
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$setOnInsert: {

@@ -609,3 +609,3 @@ requiredString: undefined,

}).toBe(9);
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$setOnInsert: {

@@ -625,3 +625,3 @@ requiredString: '',

}).toBe(7);
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$setOnInsert: {

@@ -642,3 +642,3 @@ requiredString: ' ',

(0, _expectRequiredErrorLength.default)(_friendsSchema.default, {
(0, _expectRequiredErrorLength["default"])(_friendsSchema["default"], {
$setOnInsert: {

@@ -660,3 +660,3 @@ friends: [{

// Make sure they're merged for validation purposes.
(0, _expectValid.default)(_requiredSchema.default, {
(0, _expectValid["default"])(_requiredSchema["default"], {
$set: {

@@ -680,3 +680,3 @@ requiredString: 'test',

});
(0, _expectValid.default)(_requiredSchema.default, {
(0, _expectValid["default"])(_requiredSchema["default"], {
$set: {

@@ -702,3 +702,3 @@ requiredString: 'test',

it('invalid upsert', function () {
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$setOnInsert: {},

@@ -710,3 +710,3 @@ $set: {}

}).toBe(8);
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$set: {

@@ -728,3 +728,3 @@ requiredString: null,

}).toBe(9);
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$set: {

@@ -746,3 +746,3 @@ requiredString: undefined,

}).toBe(8);
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$set: {

@@ -764,3 +764,3 @@ requiredString: '',

}).toBe(5);
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$set: {

@@ -787,3 +787,3 @@ requiredString: ' ',

// Would not cause DB changes, so should not be an error
(0, _expectValid.default)(_requiredSchema.default, {
(0, _expectValid["default"])(_requiredSchema["default"], {
$unset: {}

@@ -795,3 +795,3 @@ }, {

(0, _expectValid.default)(_requiredSchema.default, {
(0, _expectValid["default"])(_requiredSchema["default"], {
$unset: {

@@ -803,3 +803,3 @@ anOptionalOne: 1

});
(0, _expectValid.default)(_requiredSchema.default, {
(0, _expectValid["default"])(_requiredSchema["default"], {
$unset: {

@@ -811,3 +811,3 @@ anOptionalOne: null

});
(0, _expectValid.default)(_requiredSchema.default, {
(0, _expectValid["default"])(_requiredSchema["default"], {
$unset: {

@@ -819,3 +819,3 @@ anOptionalOne: ''

});
(0, _expectValid.default)(_requiredSchema.default, {
(0, _expectValid["default"])(_requiredSchema["default"], {
$unset: {

@@ -828,3 +828,3 @@ optionalObject: ''

(0, _expectValid.default)(_friendsSchema.default, {
(0, _expectValid["default"])(_friendsSchema["default"], {
$unset: {

@@ -836,3 +836,3 @@ 'friends.1.a.b': ''

});
(0, _expectValid.default)(_friendsSchema.default, {
(0, _expectValid["default"])(_friendsSchema["default"], {
$unset: {

@@ -848,3 +848,3 @@ 'friends.1.a.b': 1,

it('invalid', function () {
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$unset: {

@@ -861,3 +861,3 @@ requiredString: 1,

}).toBe(6);
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$unset: {

@@ -869,3 +869,3 @@ 'optionalObject.requiredString': 1

}).toBe(1);
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$unset: {

@@ -878,3 +878,3 @@ 'requiredObject.requiredNumber': 1

(0, _expectRequiredErrorLength.default)(_friendsSchema.default, {
(0, _expectRequiredErrorLength["default"])(_friendsSchema["default"], {
$unset: {

@@ -886,3 +886,3 @@ 'friends.1.name': 1

}).toBe(1);
(0, _expectRequiredErrorLength.default)(_friendsSchema.default, {
(0, _expectRequiredErrorLength["default"])(_friendsSchema["default"], {
$unset: {

@@ -900,3 +900,3 @@ 'friends.1.name': 1,

it('rename from optional key to another key in schema', function () {
(0, _expectValid.default)(_testSchema.default, {
(0, _expectValid["default"])(_testSchema["default"], {
$rename: {

@@ -910,3 +910,3 @@ string: 'minMaxString'

it('rename from optional key to a key not in schema', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$rename: {

@@ -920,3 +920,3 @@ string: 'newString'

it('rename from required key', function () {
(0, _expectRequiredErrorLength.default)(_requiredSchema.default, {
(0, _expectRequiredErrorLength["default"])(_requiredSchema["default"], {
$rename: {

@@ -932,3 +932,3 @@ requiredString: 'requiredUrl'

it('valid', function () {
(0, _expectRequiredErrorLength.default)(_friendsSchema.default, {
(0, _expectRequiredErrorLength["default"])(_friendsSchema["default"], {
$push: {

@@ -945,3 +945,3 @@ friends: {

it('invalid', function () {
(0, _expectRequiredErrorLength.default)(_friendsSchema.default, {
(0, _expectRequiredErrorLength["default"])(_friendsSchema["default"], {
$push: {

@@ -959,3 +959,3 @@ friends: {

it('valid', function () {
(0, _expectRequiredErrorLength.default)(_friendsSchema.default, {
(0, _expectRequiredErrorLength["default"])(_friendsSchema["default"], {
$addToSet: {

@@ -972,3 +972,3 @@ friends: {

it('invalid', function () {
(0, _expectRequiredErrorLength.default)(_friendsSchema.default, {
(0, _expectRequiredErrorLength["default"])(_friendsSchema["default"], {
$addToSet: {

@@ -975,0 +975,0 @@ friends: {

@@ -17,3 +17,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -23,3 +23,3 @@ /* eslint-disable func-names, prefer-arrow-callback */

it('typed array', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
ta: {

@@ -29,3 +29,3 @@ type: Uint8Array

});
(0, _expectErrorLength.default)(schema, {
(0, _expectErrorLength["default"])(schema, {
ta: new Uint8Array(100000000)

@@ -35,3 +35,3 @@ }).toEqual(0);

it('array of objects', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _friendsSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _friendsSchema["default"], {
$set: {

@@ -49,3 +49,3 @@ enemies: [{

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _friendsSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _friendsSchema["default"], {
$set: {

@@ -66,5 +66,5 @@ enemies: [{

it('valid', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
address: {
type: _Address.default
type: _Address["default"]
},

@@ -78,12 +78,12 @@ createdAt: {

});
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, schema, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, schema, {
createdAt: new Date(),
file: new Uint8Array([104, 101, 108, 108, 111]),
address: new _Address.default('San Francisco', 'CA')
address: new _Address["default"]('San Francisco', 'CA')
}).toEqual(0);
});
it('invalid', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
address: {
type: _Address.default
type: _Address["default"]
},

@@ -97,3 +97,3 @@ createdAt: {

});
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, schema, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, schema, {
createdAt: {},

@@ -106,3 +106,3 @@ file: {},

it('weird type', function () {
(0, _expect.default)(function () {
(0, _expect["default"])(function () {
new _SimpleSchema.SimpleSchema({

@@ -118,12 +118,12 @@ // eslint-disable-line no-new

it('normal', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
string: 'test'
}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
string: true
}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
string: 1
}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
string: {

@@ -133,6 +133,6 @@ test: 'test'

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
string: ['test']
}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
string: new Date()

@@ -142,3 +142,3 @@ }).toEqual(1);

it('modifier with $setOnInsert', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -151,3 +151,3 @@ string: 'test'

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -160,3 +160,3 @@ string: true

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -169,3 +169,3 @@ string: 1

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -180,3 +180,3 @@ string: {

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -189,3 +189,3 @@ string: ['test']

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -200,3 +200,3 @@ string: new Date()

it('modifier with $set', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -208,3 +208,3 @@ string: 'test'

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -216,3 +216,3 @@ string: true

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -224,3 +224,3 @@ string: 1

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -234,3 +234,3 @@ string: {

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -242,3 +242,3 @@ string: ['test']

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -252,3 +252,3 @@ string: new Date()

it('modifier with $push', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -260,3 +260,3 @@ allowedStringsArray: 'test'

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -268,3 +268,3 @@ allowedStringsArray: true

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -276,3 +276,3 @@ allowedStringsArray: 1

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -286,3 +286,3 @@ allowedStringsArray: {

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -294,3 +294,3 @@ allowedStringsArray: ['test']

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -304,3 +304,3 @@ allowedStringsArray: new Date()

it('modifier with $addToSet', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -312,3 +312,3 @@ allowedStringsArray: 'test'

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -320,3 +320,3 @@ allowedStringsArray: true

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -328,3 +328,3 @@ allowedStringsArray: 1

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -338,3 +338,3 @@ allowedStringsArray: {

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -346,3 +346,3 @@ allowedStringsArray: ['test']

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -356,3 +356,3 @@ allowedStringsArray: new Date()

it('modifier with $push + $each', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -366,3 +366,3 @@ allowedStringsArray: {

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -376,3 +376,3 @@ allowedStringsArray: {

}).toEqual(2);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -386,3 +386,3 @@ allowedStringsArray: {

}).toEqual(2);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -400,3 +400,3 @@ allowedStringsArray: {

}).toEqual(2);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -410,3 +410,3 @@ allowedStringsArray: {

}).toEqual(2);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -424,30 +424,30 @@ allowedStringsArray: {

it('normal', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
boolean: true
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
"boolean": true
}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
boolean: false
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
"boolean": false
}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
boolean: 'true'
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
"boolean": 'true'
}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
boolean: 0
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
"boolean": 0
}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
boolean: {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
"boolean": {
test: true
}
}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
boolean: [false]
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
"boolean": [false]
}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
boolean: new Date()
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
"boolean": new Date()
}).toEqual(1);
});
it('modifier with $setOnInsert', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {
boolean: true
"boolean": true
}

@@ -458,5 +458,5 @@ }, {

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {
boolean: false
"boolean": false
}

@@ -467,5 +467,5 @@ }, {

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {
boolean: 'true'
"boolean": 'true'
}

@@ -476,5 +476,5 @@ }, {

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {
boolean: 0
"boolean": 0
}

@@ -485,5 +485,5 @@ }, {

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {
boolean: {
"boolean": {
test: true

@@ -496,5 +496,5 @@ }

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {
boolean: [false]
"boolean": [false]
}

@@ -505,5 +505,5 @@ }, {

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {
boolean: new Date()
"boolean": new Date()
}

@@ -516,5 +516,5 @@ }, {

it('modifier with $set', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {
boolean: true
"boolean": true
}

@@ -524,5 +524,5 @@ }, {

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {
boolean: false
"boolean": false
}

@@ -532,5 +532,5 @@ }, {

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {
boolean: 'true'
"boolean": 'true'
}

@@ -540,5 +540,5 @@ }, {

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {
boolean: 0
"boolean": 0
}

@@ -548,5 +548,5 @@ }, {

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {
boolean: {
"boolean": {
test: true

@@ -558,5 +558,5 @@ }

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {
boolean: [false]
"boolean": [false]
}

@@ -566,5 +566,5 @@ }, {

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {
boolean: new Date()
"boolean": new Date()
}

@@ -576,3 +576,3 @@ }, {

it('modifier with $push', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -584,3 +584,3 @@ booleanArray: true

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -592,3 +592,3 @@ booleanArray: false

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -600,3 +600,3 @@ booleanArray: 'true'

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -608,3 +608,3 @@ booleanArray: 0

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -618,3 +618,3 @@ booleanArray: {

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -626,3 +626,3 @@ booleanArray: [false]

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -636,3 +636,3 @@ booleanArray: new Date()

it('modifier with $addToSet', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -644,3 +644,3 @@ booleanArray: true

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -652,3 +652,3 @@ booleanArray: false

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -660,3 +660,3 @@ booleanArray: 'true'

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -668,3 +668,3 @@ booleanArray: 0

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -678,3 +678,3 @@ booleanArray: {

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -686,3 +686,3 @@ booleanArray: [false]

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -696,3 +696,3 @@ booleanArray: new Date()

it('modifier with $push + $each', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -706,3 +706,3 @@ booleanArray: {

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -716,3 +716,3 @@ booleanArray: {

}).toEqual(2);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -726,3 +726,3 @@ booleanArray: {

}).toEqual(2);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -740,3 +740,3 @@ booleanArray: {

}).toEqual(2);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -750,3 +750,3 @@ booleanArray: {

}).toEqual(2);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -764,15 +764,15 @@ booleanArray: {

it('normal', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
number: 1
}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
number: 0
}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
number: 'test'
}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
number: false
}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
number: {

@@ -782,10 +782,10 @@ test: 1

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
number: [1]
}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
number: new Date()
}).toEqual(1); // NaN does not count
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
number: NaN

@@ -795,3 +795,3 @@ }).toEqual(1);

it('modifier with $setOnInsert', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -804,3 +804,3 @@ number: 1

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -813,3 +813,3 @@ number: 0

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -822,3 +822,3 @@ number: 'test'

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -831,3 +831,3 @@ number: false

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -842,3 +842,3 @@ number: {

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -851,3 +851,3 @@ number: [1]

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -861,3 +861,3 @@ number: new Date()

(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -872,3 +872,3 @@ number: NaN

it('modifier with $set', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -880,3 +880,3 @@ number: 1

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -888,3 +888,3 @@ number: 0

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -896,3 +896,3 @@ number: 'test'

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -904,3 +904,3 @@ number: false

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -914,3 +914,3 @@ number: {

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -922,3 +922,3 @@ number: [1]

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -931,3 +931,3 @@ number: new Date()

(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -941,3 +941,3 @@ number: NaN

it('modifier with $push', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -949,3 +949,3 @@ allowedNumbersArray: 1

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -957,3 +957,3 @@ allowedNumbersArray: 0

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -965,3 +965,3 @@ allowedNumbersArray: 'test'

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -973,3 +973,3 @@ allowedNumbersArray: false

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -983,3 +983,3 @@ allowedNumbersArray: {

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -991,3 +991,3 @@ allowedNumbersArray: [1]

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -1000,3 +1000,3 @@ allowedNumbersArray: new Date()

(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -1010,3 +1010,3 @@ allowedNumbersArray: NaN

it('modifier with $addToSet', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -1018,3 +1018,3 @@ allowedNumbersArray: 1

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -1026,3 +1026,3 @@ allowedNumbersArray: 0

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -1034,3 +1034,3 @@ allowedNumbersArray: 'test'

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -1042,3 +1042,3 @@ allowedNumbersArray: false

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -1052,3 +1052,3 @@ allowedNumbersArray: {

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -1060,3 +1060,3 @@ allowedNumbersArray: [1]

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -1069,3 +1069,3 @@ allowedNumbersArray: new Date()

(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -1079,3 +1079,3 @@ allowedNumbersArray: NaN

it('modifier with $push + $each', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -1089,3 +1089,3 @@ allowedNumbersArray: {

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -1099,3 +1099,3 @@ allowedNumbersArray: {

}).toEqual(2);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -1109,3 +1109,3 @@ allowedNumbersArray: {

}).toEqual(2);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -1123,3 +1123,3 @@ allowedNumbersArray: {

}).toEqual(2);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -1133,3 +1133,3 @@ allowedNumbersArray: {

}).toEqual(2);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -1144,3 +1144,3 @@ allowedNumbersArray: {

(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -1158,12 +1158,12 @@ allowedNumbersArray: {

it('normal', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
date: new Date()
}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
date: 'test'
}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
date: false
}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
date: {

@@ -1173,6 +1173,6 @@ test: new Date()

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
date: [new Date()]
}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
date: 1

@@ -1182,3 +1182,3 @@ }).toEqual(1);

it('modifier with $setOnInsert', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -1191,3 +1191,3 @@ date: new Date()

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -1200,3 +1200,3 @@ date: 'test'

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -1209,3 +1209,3 @@ date: false

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -1220,3 +1220,3 @@ date: {

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -1229,3 +1229,3 @@ date: [new Date()]

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -1240,3 +1240,3 @@ date: 1

it('modifier with $set', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -1248,3 +1248,3 @@ date: new Date()

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -1256,3 +1256,3 @@ date: 'test'

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -1264,3 +1264,3 @@ date: false

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -1274,3 +1274,3 @@ date: {

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -1282,3 +1282,3 @@ date: [new Date()]

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -1292,3 +1292,3 @@ date: 1

it('modifier with $push', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -1300,3 +1300,3 @@ dateArray: new Date()

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -1308,3 +1308,3 @@ dateArray: 'test'

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -1316,3 +1316,3 @@ dateArray: false

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -1326,3 +1326,3 @@ dateArray: {

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -1334,3 +1334,3 @@ dateArray: [new Date()]

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -1344,3 +1344,3 @@ dateArray: 1

it('modifier with $addToSet', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -1352,3 +1352,3 @@ dateArray: new Date()

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -1360,3 +1360,3 @@ dateArray: 'test'

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -1368,3 +1368,3 @@ dateArray: false

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -1378,3 +1378,3 @@ dateArray: {

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -1386,3 +1386,3 @@ dateArray: [new Date()]

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$addToSet: {

@@ -1396,3 +1396,3 @@ dateArray: 1

it('modifier with $push + $each', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -1406,3 +1406,3 @@ dateArray: {

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -1416,3 +1416,3 @@ dateArray: {

}).toEqual(2);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -1426,3 +1426,3 @@ dateArray: {

}).toEqual(2);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -1440,3 +1440,3 @@ dateArray: {

}).toEqual(2);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -1450,3 +1450,3 @@ dateArray: {

}).toEqual(2);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$push: {

@@ -1464,18 +1464,18 @@ dateArray: {

it('normal', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
booleanArray: []
}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
booleanArray: [true]
}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
booleanArray: [false]
}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
booleanArray: 'test'
}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
booleanArray: false
}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
booleanArray: {

@@ -1485,6 +1485,6 @@ test: []

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
booleanArray: ['test']
}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
booleanArray: 1

@@ -1494,3 +1494,3 @@ }).toEqual(1);

it('modifier with $setOnInsert', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -1503,3 +1503,3 @@ booleanArray: [true, false]

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -1512,3 +1512,3 @@ booleanArray: 'test'

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -1521,3 +1521,3 @@ booleanArray: false

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -1532,3 +1532,3 @@ booleanArray: {

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -1541,3 +1541,3 @@ booleanArray: new Date()

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$setOnInsert: {

@@ -1552,3 +1552,3 @@ booleanArray: 1

it('modifier with $set', function () {
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -1560,3 +1560,3 @@ booleanArray: [true, false]

}).toEqual(0);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -1568,3 +1568,3 @@ booleanArray: 'test'

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -1576,3 +1576,3 @@ booleanArray: false

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -1586,3 +1586,3 @@ booleanArray: {

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -1594,3 +1594,3 @@ booleanArray: new Date()

}).toEqual(1);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema.default, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, _testSchema["default"], {
$set: {

@@ -1604,3 +1604,3 @@ booleanArray: 1

it('ignores slice', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$push: {

@@ -1629,3 +1629,3 @@ booleanArray: {

it('ignores pull', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$pull: {

@@ -1642,3 +1642,3 @@ booleanArray: 'foo',

it('ignores pull + $each', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$pull: {

@@ -1663,3 +1663,3 @@ booleanArray: {

it('ignores pullAll', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$pullAll: {

@@ -1676,3 +1676,3 @@ booleanArray: ['foo', 'bar'],

it('ignores pop', function () {
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$pop: {

@@ -1687,3 +1687,3 @@ booleanArray: 1,

}).toEqual(0);
(0, _expectErrorLength.default)(_testSchema.default, {
(0, _expectErrorLength["default"])(_testSchema["default"], {
$pop: {

@@ -1690,0 +1690,0 @@ booleanArray: -1,

@@ -8,4 +8,4 @@ "use strict";

enumerable: true,
get: function () {
return _ValidationContext.default;
get: function get() {
return _ValidationContext["default"];
}

@@ -19,3 +19,3 @@ });

var _extend = _interopRequireDefault(require("extend"));
var _extend2 = _interopRequireDefault(require("extend"));

@@ -44,3 +44,3 @@ var _lodash2 = _interopRequireDefault(require("lodash.includes"));

var _clean = _interopRequireDefault(require("./clean"));
var _clean2 = _interopRequireDefault(require("./clean"));

@@ -53,23 +53,54 @@ var _expandShorthand = _interopRequireDefault(require("./expandShorthand"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
function _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
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; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
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; }
// Exported for tests
const schemaDefinitionOptions = ['type', 'label', 'optional', 'required', 'autoValue', 'defaultValue'];
var schemaDefinitionOptions = ['type', 'label', 'optional', 'required', 'autoValue', 'defaultValue'];
exports.schemaDefinitionOptions = schemaDefinitionOptions;
const oneOfProps = ['type', 'min', 'max', 'minCount', 'maxCount', 'allowedValues', 'exclusiveMin', 'exclusiveMax', 'regEx', 'custom', 'blackbox', 'trim'];
const propsThatCanBeFunction = ['label', 'optional', 'min', 'max', 'minCount', 'maxCount', 'allowedValues', 'exclusiveMin', 'exclusiveMax', 'regEx'];
var oneOfProps = ['type', 'min', 'max', 'minCount', 'maxCount', 'allowedValues', 'exclusiveMin', 'exclusiveMax', 'regEx', 'custom', 'blackbox', 'trim'];
var propsThatCanBeFunction = ['label', 'optional', 'min', 'max', 'minCount', 'maxCount', 'allowedValues', 'exclusiveMin', 'exclusiveMax', 'regEx'];
class SimpleSchema {
constructor(schema = {}, {
check,
clean: cleanOptions,
defaultLabel,
humanizeAutoLabels = true,
requiredByDefault = true,
tracker
} = {}) {
var SimpleSchema =
/*#__PURE__*/
function () {
function SimpleSchema() {
var schema = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
check = _ref.check,
cleanOptions = _ref.clean,
defaultLabel = _ref.defaultLabel,
_ref$humanizeAutoLabe = _ref.humanizeAutoLabels,
humanizeAutoLabels = _ref$humanizeAutoLabe === void 0 ? true : _ref$humanizeAutoLabe,
_ref$requiredByDefaul = _ref.requiredByDefault,
requiredByDefault = _ref$requiredByDefaul === void 0 ? true : _ref$requiredByDefaul,
tracker = _ref.tracker;
_classCallCheck(this, SimpleSchema);
_defineProperty(this, "pick", getPickOrOmit('pick'));

@@ -81,7 +112,7 @@

this._constructorOptions = {
check,
defaultLabel,
humanizeAutoLabels,
requiredByDefault,
tracker
check: check,
defaultLabel: defaultLabel,
humanizeAutoLabels: humanizeAutoLabels,
requiredByDefault: requiredByDefault,
tracker: tracker
}; // Custom validators for this instance

@@ -108,730 +139,816 @@

this.messageBox = new _messageBox.default((0, _clone.default)(_defaultMessages.default));
this.messageBox = new _messageBox["default"]((0, _clone["default"])(_defaultMessages["default"]));
this.version = SimpleSchema.version;
}
forEachAncestorSimpleSchema(key, func) {
const genericKey = _mongoObject.default.makeKeyGeneric(key);
_createClass(SimpleSchema, [{
key: "forEachAncestorSimpleSchema",
value: function forEachAncestorSimpleSchema(key, func) {
var _this = this;
(0, _utility.forEachKeyAncestor)(genericKey, ancestor => {
const def = this._schema[ancestor];
if (!def) return;
def.type.definitions.forEach(typeDef => {
if (SimpleSchema.isSimpleSchema(typeDef.type)) {
func(typeDef.type, ancestor, genericKey.slice(ancestor.length + 1));
}
var genericKey = _mongoObject["default"].makeKeyGeneric(key);
(0, _utility.forEachKeyAncestor)(genericKey, function (ancestor) {
var def = _this._schema[ancestor];
if (!def) return;
def.type.definitions.forEach(function (typeDef) {
if (SimpleSchema.isSimpleSchema(typeDef.type)) {
func(typeDef.type, ancestor, genericKey.slice(ancestor.length + 1));
}
});
});
});
}
/**
* Returns whether the obj is a SimpleSchema object.
* @param {Object} [obj] An object to test
* @returns {Boolean} True if the given object appears to be a SimpleSchema instance
*/
}
/**
* Returns whether the obj is a SimpleSchema object.
* @param {Object} [obj] An object to test
* @returns {Boolean} True if the given object appears to be a SimpleSchema instance
*/
}, {
key: "reactiveLabelDependency",
static isSimpleSchema(obj) {
return obj && (obj instanceof SimpleSchema || obj._schema);
}
/**
* For Meteor apps, add a reactive dependency on the label
* for a key.
*/
/**
* For Meteor apps, add a reactive dependency on the label
* for a key.
*/
value: function reactiveLabelDependency(key) {
var tracker = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._constructorOptions.tracker;
if (!key || !tracker) return;
var genericKey = _mongoObject["default"].makeKeyGeneric(key); // If in this schema
reactiveLabelDependency(key, tracker = this._constructorOptions.tracker) {
if (!key || !tracker) return;
const genericKey = _mongoObject.default.makeKeyGeneric(key); // If in this schema
if (this._schema[genericKey]) {
if (!this._depsLabels[genericKey]) {
this._depsLabels[genericKey] = new tracker.Dependency();
}
this._depsLabels[genericKey].depend();
if (this._schema[genericKey]) {
if (!this._depsLabels[genericKey]) {
this._depsLabels[genericKey] = new tracker.Dependency();
}
return;
} // If in subschema
this._depsLabels[genericKey].depend();
return;
} // If in subschema
this.forEachAncestorSimpleSchema(key, function (simpleSchema, ancestor, subSchemaKey) {
// Pass tracker down so that we get reactivity even if the subschema
// didn't have tracker option set
simpleSchema.reactiveLabelDependency(subSchemaKey, tracker);
});
}
/**
* @param {String} [key] One specific or generic key for which to get the schema.
* @returns {Object} The entire schema object or just the definition for one key.
*
* Note that this returns the raw, unevaluated definition object. Use `getDefinition`
* if you want the evaluated definition, where any properties that are functions
* have been run to produce a result.
*/
}, {
key: "schema",
value: function schema(key) {
if (!key) return this._schema;
this.forEachAncestorSimpleSchema(key, (simpleSchema, ancestor, subSchemaKey) => {
// Pass tracker down so that we get reactivity even if the subschema
// didn't have tracker option set
simpleSchema.reactiveLabelDependency(subSchemaKey, tracker);
});
}
/**
* @param {String} [key] One specific or generic key for which to get the schema.
* @returns {Object} The entire schema object or just the definition for one key.
*
* Note that this returns the raw, unevaluated definition object. Use `getDefinition`
* if you want the evaluated definition, where any properties that are functions
* have been run to produce a result.
*/
var genericKey = _mongoObject["default"].makeKeyGeneric(key);
var keySchema = this._schema[genericKey]; // If not defined in this schema, see if it's defined in a subschema
schema(key) {
if (!key) return this._schema;
if (!keySchema) {
var found = false;
this.forEachAncestorSimpleSchema(key, function (simpleSchema, ancestor, subSchemaKey) {
if (!found) keySchema = simpleSchema.schema(subSchemaKey);
if (keySchema) found = true;
});
}
const genericKey = _mongoObject.default.makeKeyGeneric(key);
let keySchema = this._schema[genericKey]; // If not defined in this schema, see if it's defined in a subschema
if (!keySchema) {
let found = false;
this.forEachAncestorSimpleSchema(key, (simpleSchema, ancestor, subSchemaKey) => {
if (!found) keySchema = simpleSchema.schema(subSchemaKey);
if (keySchema) found = true;
});
return keySchema;
}
/**
* @returns {Object} The entire schema object with subschemas merged. This is the
* equivalent of what schema() returned in SimpleSchema < 2.0
*
* Note that this returns the raw, unevaluated definition object. Use `getDefinition`
* if you want the evaluated definition, where any properties that are functions
* have been run to produce a result.
*/
return keySchema;
}
/**
* @returns {Object} The entire schema object with subschemas merged. This is the
* equivalent of what schema() returned in SimpleSchema < 2.0
*
* Note that this returns the raw, unevaluated definition object. Use `getDefinition`
* if you want the evaluated definition, where any properties that are functions
* have been run to produce a result.
*/
}, {
key: "mergedSchema",
value: function mergedSchema() {
var _this2 = this;
var mergedSchema = {};
mergedSchema() {
const mergedSchema = {};
this._schemaKeys.forEach(key => {
const keySchema = this._schema[key];
mergedSchema[key] = keySchema;
keySchema.type.definitions.forEach(typeDef => {
if (!SimpleSchema.isSimpleSchema(typeDef.type)) return;
const childSchema = typeDef.type.mergedSchema();
Object.keys(childSchema).forEach(subKey => {
mergedSchema[`${key}.${subKey}`] = childSchema[subKey];
this._schemaKeys.forEach(function (key) {
var keySchema = _this2._schema[key];
mergedSchema[key] = keySchema;
keySchema.type.definitions.forEach(function (typeDef) {
if (!SimpleSchema.isSimpleSchema(typeDef.type)) return;
var childSchema = typeDef.type.mergedSchema();
Object.keys(childSchema).forEach(function (subKey) {
mergedSchema["".concat(key, ".").concat(subKey)] = childSchema[subKey];
});
});
});
});
return mergedSchema;
}
/**
* Returns the evaluated definition for one key in the schema
*
* @param {String} key Generic or specific schema key
* @param {Array(String)} [propList] Array of schema properties you need; performance optimization
* @param {Object} [functionContext] The context to use when evaluating schema options that are functions
* @returns {Object} The schema definition for the requested key
*/
return mergedSchema;
}
/**
* Returns the evaluated definition for one key in the schema
*
* @param {String} key Generic or specific schema key
* @param {Array(String)} [propList] Array of schema properties you need; performance optimization
* @param {Object} [functionContext] The context to use when evaluating schema options that are functions
* @returns {Object} The schema definition for the requested key
*/
}, {
key: "getDefinition",
value: function getDefinition(key, propList) {
var _this3 = this;
getDefinition(key, propList, functionContext = {}) {
const defs = this.schema(key);
if (!defs) return;
var functionContext = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var defs = this.schema(key);
if (!defs) return;
const getPropIterator = (obj, newObj) => {
return prop => {
if (Array.isArray(propList) && !(0, _lodash2.default)(propList, prop)) return;
const val = obj[prop]; // For any options that support specifying a function, evaluate the functions
var getPropIterator = function getPropIterator(obj, newObj) {
return function (prop) {
if (Array.isArray(propList) && !(0, _lodash2["default"])(propList, prop)) return;
var val = obj[prop]; // For any options that support specifying a function, evaluate the functions
if (propsThatCanBeFunction.indexOf(prop) > -1 && typeof val === 'function') {
newObj[prop] = val.call(_objectSpread({
key
}, functionContext)); // Inflect label if undefined
if (propsThatCanBeFunction.indexOf(prop) > -1 && typeof val === 'function') {
newObj[prop] = val.call(_objectSpread({
key: key
}, functionContext)); // Inflect label if undefined
if (prop === 'label' && typeof newObj[prop] !== 'string') newObj[prop] = inflectedLabel(key, this._constructorOptions.humanizeAutoLabels);
} else {
newObj[prop] = val;
}
if (prop === 'label' && typeof newObj[prop] !== 'string') newObj[prop] = inflectedLabel(key, _this3._constructorOptions.humanizeAutoLabels);
} else {
newObj[prop] = val;
}
};
};
};
const result = {};
Object.keys(defs).forEach(getPropIterator(defs, result)); // Resolve all the types and convert to a normal array to make it easier
// to use.
var result = {};
Object.keys(defs).forEach(getPropIterator(defs, result)); // Resolve all the types and convert to a normal array to make it easier
// to use.
if (defs.type) {
result.type = defs.type.definitions.map(typeDef => {
const newTypeDef = {};
Object.keys(typeDef).forEach(getPropIterator(typeDef, newTypeDef));
return newTypeDef;
});
if (defs.type) {
result.type = defs.type.definitions.map(function (typeDef) {
var newTypeDef = {};
Object.keys(typeDef).forEach(getPropIterator(typeDef, newTypeDef));
return newTypeDef;
});
}
return result;
}
/**
* Returns a string identifying the best guess data type for a key. For keys
* that allow multiple types, the first type is used. This can be useful for
* building forms.
*
* @param {String} key Generic or specific schema key
* @returns {String} A type string. One of:
* string, number, boolean, date, object, stringArray, numberArray, booleanArray,
* dateArray, objectArray
*/
return result;
}
/**
* Returns a string identifying the best guess data type for a key. For keys
* that allow multiple types, the first type is used. This can be useful for
* building forms.
*
* @param {String} key Generic or specific schema key
* @returns {String} A type string. One of:
* string, number, boolean, date, object, stringArray, numberArray, booleanArray,
* dateArray, objectArray
*/
}, {
key: "getQuickTypeForKey",
value: function getQuickTypeForKey(key) {
var type;
var fieldSchema = this.schema(key);
if (!fieldSchema) return;
var fieldType = fieldSchema.type.singleType;
if (fieldType === String) {
type = 'string';
} else if (fieldType === Number || fieldType === SimpleSchema.Integer) {
type = 'number';
} else if (fieldType === Boolean) {
type = 'boolean';
} else if (fieldType === Date) {
type = 'date';
} else if (fieldType === Array) {
var arrayItemFieldSchema = this.schema("".concat(key, ".$"));
if (!arrayItemFieldSchema) return;
var arrayItemFieldType = arrayItemFieldSchema.type.singleType;
getQuickTypeForKey(key) {
let type;
const fieldSchema = this.schema(key);
if (!fieldSchema) return;
const fieldType = fieldSchema.type.singleType;
if (arrayItemFieldType === String) {
type = 'stringArray';
} else if (arrayItemFieldType === Number || arrayItemFieldType === SimpleSchema.Integer) {
type = 'numberArray';
} else if (arrayItemFieldType === Boolean) {
type = 'booleanArray';
} else if (arrayItemFieldType === Date) {
type = 'dateArray';
} else if (arrayItemFieldType === Object || SimpleSchema.isSimpleSchema(arrayItemFieldType)) {
type = 'objectArray';
}
} else if (fieldType === Object) {
type = 'object';
}
if (fieldType === String) {
type = 'string';
} else if (fieldType === Number || fieldType === SimpleSchema.Integer) {
type = 'number';
} else if (fieldType === Boolean) {
type = 'boolean';
} else if (fieldType === Date) {
type = 'date';
} else if (fieldType === Array) {
const arrayItemFieldSchema = this.schema(`${key}.$`);
if (!arrayItemFieldSchema) return;
const arrayItemFieldType = arrayItemFieldSchema.type.singleType;
if (arrayItemFieldType === String) {
type = 'stringArray';
} else if (arrayItemFieldType === Number || arrayItemFieldType === SimpleSchema.Integer) {
type = 'numberArray';
} else if (arrayItemFieldType === Boolean) {
type = 'booleanArray';
} else if (arrayItemFieldType === Date) {
type = 'dateArray';
} else if (arrayItemFieldType === Object || SimpleSchema.isSimpleSchema(arrayItemFieldType)) {
type = 'objectArray';
}
} else if (fieldType === Object) {
type = 'object';
return type;
}
/**
* Given a key that is an Object, returns a new SimpleSchema instance scoped to that object.
*
* @param {String} key Generic or specific schema key
*/
return type;
}
/**
* Given a key that is an Object, returns a new SimpleSchema instance scoped to that object.
*
* @param {String} key Generic or specific schema key
*/
}, {
key: "getObjectSchema",
value: function getObjectSchema(key) {
var newSchemaDef = {};
var genericKey = _mongoObject["default"].makeKeyGeneric(key);
getObjectSchema(key) {
const newSchemaDef = {};
var searchString = "".concat(genericKey, ".");
var mergedSchema = this.mergedSchema();
Object.keys(mergedSchema).forEach(function (k) {
if (k.indexOf(searchString) === 0) {
newSchemaDef[k.slice(searchString.length)] = mergedSchema[k];
}
});
return this._copyWithSchema(newSchemaDef);
} // Returns an array of all the autovalue functions, including those in subschemas all the
// way down the schema tree
const genericKey = _mongoObject.default.makeKeyGeneric(key);
}, {
key: "autoValueFunctions",
value: function autoValueFunctions() {
var _this4 = this;
const searchString = `${genericKey}.`;
const mergedSchema = this.mergedSchema();
Object.keys(mergedSchema).forEach(k => {
if (k.indexOf(searchString) === 0) {
newSchemaDef[k.slice(searchString.length)] = mergedSchema[k];
}
});
return this._copyWithSchema(newSchemaDef);
} // Returns an array of all the autovalue functions, including those in subschemas all the
// way down the schema tree
var result = [].concat(this._autoValues);
autoValueFunctions() {
let result = [].concat(this._autoValues);
this._schemaKeys.forEach(key => {
this._schema[key].type.definitions.forEach(typeDef => {
if (!SimpleSchema.isSimpleSchema(typeDef.type)) return;
result = result.concat(typeDef.type.autoValueFunctions().map(({
func,
fieldName,
closestSubschemaFieldName
}) => {
return {
func,
fieldName: `${key}.${fieldName}`,
closestSubschemaFieldName: closestSubschemaFieldName.length ? `${key}.${closestSubschemaFieldName}` : key
};
}));
this._schemaKeys.forEach(function (key) {
_this4._schema[key].type.definitions.forEach(function (typeDef) {
if (!SimpleSchema.isSimpleSchema(typeDef.type)) return;
result = result.concat(typeDef.type.autoValueFunctions().map(function (_ref2) {
var func = _ref2.func,
fieldName = _ref2.fieldName,
closestSubschemaFieldName = _ref2.closestSubschemaFieldName;
return {
func: func,
fieldName: "".concat(key, ".").concat(fieldName),
closestSubschemaFieldName: closestSubschemaFieldName.length ? "".concat(key, ".").concat(closestSubschemaFieldName) : key
};
}));
});
});
});
return result;
} // Returns an array of all the blackbox keys, including those in subschemas
return result;
} // Returns an array of all the blackbox keys, including those in subschemas
}, {
key: "blackboxKeys",
value: function blackboxKeys() {
var _this5 = this;
blackboxKeys() {
const blackboxKeys = this._blackboxKeys;
var blackboxKeys = this._blackboxKeys;
this._schemaKeys.forEach(key => {
this._schema[key].type.definitions.forEach(typeDef => {
if (!SimpleSchema.isSimpleSchema(typeDef.type)) return;
this._schemaKeys.forEach(function (key) {
_this5._schema[key].type.definitions.forEach(function (typeDef) {
if (!SimpleSchema.isSimpleSchema(typeDef.type)) return;
typeDef.type._blackboxKeys.forEach(blackboxKey => {
blackboxKeys.push(`${key}.${blackboxKey}`);
typeDef.type._blackboxKeys.forEach(function (blackboxKey) {
blackboxKeys.push("".concat(key, ".").concat(blackboxKey));
});
});
});
});
return (0, _lodash6.default)(blackboxKeys);
} // Check if the key is a nested dot-syntax key inside of a blackbox object
return (0, _lodash6["default"])(blackboxKeys);
} // Check if the key is a nested dot-syntax key inside of a blackbox object
}, {
key: "keyIsInBlackBox",
value: function keyIsInBlackBox(key) {
var _this6 = this;
keyIsInBlackBox(key) {
let isInBlackBox = false;
(0, _utility.forEachKeyAncestor)(_mongoObject.default.makeKeyGeneric(key), (ancestor, remainder) => {
if (this._blackboxKeys.indexOf(ancestor) > -1) {
isInBlackBox = true;
} else {
const testKeySchema = this.schema(ancestor);
var isInBlackBox = false;
(0, _utility.forEachKeyAncestor)(_mongoObject["default"].makeKeyGeneric(key), function (ancestor, remainder) {
if (_this6._blackboxKeys.indexOf(ancestor) > -1) {
isInBlackBox = true;
} else {
var testKeySchema = _this6.schema(ancestor);
if (testKeySchema) {
testKeySchema.type.definitions.forEach(typeDef => {
if (!SimpleSchema.isSimpleSchema(typeDef.type)) return;
if (typeDef.type.keyIsInBlackBox(remainder)) isInBlackBox = true;
});
if (testKeySchema) {
testKeySchema.type.definitions.forEach(function (typeDef) {
if (!SimpleSchema.isSimpleSchema(typeDef.type)) return;
if (typeDef.type.keyIsInBlackBox(remainder)) isInBlackBox = true;
});
}
}
}
});
return isInBlackBox;
} // Returns true if key is explicitly allowed by the schema or implied
// by other explicitly allowed keys.
// The key string should have $ in place of any numeric array positions.
});
return isInBlackBox;
} // Returns true if key is explicitly allowed by the schema or implied
// by other explicitly allowed keys.
// The key string should have $ in place of any numeric array positions.
}, {
key: "allowsKey",
value: function allowsKey(key) {
var _this7 = this;
allowsKey(key) {
// Loop through all keys in the schema
return this._schemaKeys.some(loopKey => {
// If the schema key is the test key, it's allowed.
if (loopKey === key) return true;
const fieldSchema = this.schema(loopKey);
const compare1 = key.slice(0, loopKey.length + 2);
const compare2 = compare1.slice(0, -1); // Blackbox and subschema checks are needed only if key starts with
// loopKey + a dot
// Loop through all keys in the schema
return this._schemaKeys.some(function (loopKey) {
// If the schema key is the test key, it's allowed.
if (loopKey === key) return true;
if (compare2 !== `${loopKey}.`) return false; // Black box handling
var fieldSchema = _this7.schema(loopKey);
if (this._blackboxKeys.indexOf(loopKey) > -1) {
// If the test key is the black box key + ".$", then the test
// key is NOT allowed because black box keys are by definition
// only for objects, and not for arrays.
return compare1 !== `${loopKey}.$`;
} // Subschemas
var compare1 = key.slice(0, loopKey.length + 2);
var compare2 = compare1.slice(0, -1); // Blackbox and subschema checks are needed only if key starts with
// loopKey + a dot
if (compare2 !== "".concat(loopKey, ".")) return false; // Black box handling
let allowed = false;
const subKey = key.slice(loopKey.length + 1);
fieldSchema.type.definitions.forEach(typeDef => {
if (!SimpleSchema.isSimpleSchema(typeDef.type)) return;
if (typeDef.type.allowsKey(subKey)) allowed = true;
});
return allowed;
});
}
/**
* Returns all the child keys for the object identified by the generic prefix,
* or all the top level keys if no prefix is supplied.
*
* @param {String} [keyPrefix] The Object-type generic key for which to get child keys. Omit for
* top-level Object-type keys
* @returns {[[Type]]} [[Description]]
*/
if (_this7._blackboxKeys.indexOf(loopKey) > -1) {
// If the test key is the black box key + ".$", then the test
// key is NOT allowed because black box keys are by definition
// only for objects, and not for arrays.
return compare1 !== "".concat(loopKey, ".$");
} // Subschemas
objectKeys(keyPrefix) {
if (!keyPrefix) return this._firstLevelSchemaKeys;
return this._objectKeys[`${keyPrefix}.`] || [];
}
/**
* Copies this schema into a new instance with the same validators, messages,
* and options, but with different keys as defined in `schema` argument
*
* @param {Object} schema
* @returns The new SimpleSchema instance (chainable)
*/
var allowed = false;
var subKey = key.slice(loopKey.length + 1);
fieldSchema.type.definitions.forEach(function (typeDef) {
if (!SimpleSchema.isSimpleSchema(typeDef.type)) return;
if (typeDef.type.allowsKey(subKey)) allowed = true;
});
return allowed;
});
}
/**
* Returns all the child keys for the object identified by the generic prefix,
* or all the top level keys if no prefix is supplied.
*
* @param {String} [keyPrefix] The Object-type generic key for which to get child keys. Omit for
* top-level Object-type keys
* @returns {[[Type]]} [[Description]]
*/
}, {
key: "objectKeys",
value: function objectKeys(keyPrefix) {
if (!keyPrefix) return this._firstLevelSchemaKeys;
return this._objectKeys["".concat(keyPrefix, ".")] || [];
}
/**
* Copies this schema into a new instance with the same validators, messages,
* and options, but with different keys as defined in `schema` argument
*
* @param {Object} schema
* @returns The new SimpleSchema instance (chainable)
*/
_copyWithSchema(schema) {
const cl = new SimpleSchema(schema, (0, _clone.default)(this._constructorOptions, false, 1));
cl._cleanOptions = this._cleanOptions;
cl.messageBox = this.messageBox.clone();
return cl;
}
/**
* Clones this schema into a new instance with the same schema keys, validators,
* and options.
*
* @returns The new SimpleSchema instance (chainable)
*/
}, {
key: "_copyWithSchema",
value: function _copyWithSchema(schema) {
var cl = new SimpleSchema(schema, (0, _clone["default"])(this._constructorOptions, false, 1));
cl._cleanOptions = this._cleanOptions;
cl.messageBox = this.messageBox.clone();
return cl;
}
/**
* Clones this schema into a new instance with the same schema keys, validators,
* and options.
*
* @returns The new SimpleSchema instance (chainable)
*/
}, {
key: "clone",
value: function clone() {
return this._copyWithSchema(this._schema);
}
/**
* Extends (mutates) this schema with another schema, key by key.
*
* @param {SimpleSchema|Object} schema
* @returns The SimpleSchema instance (chainable)
*/
clone() {
return this._copyWithSchema(this._schema);
}
/**
* Extends (mutates) this schema with another schema, key by key.
*
* @param {SimpleSchema|Object} schema
* @returns The SimpleSchema instance (chainable)
*/
}, {
key: "extend",
value: function extend() {
var _this8 = this;
var schema = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
if (Array.isArray(schema)) throw new Error('You may not pass an array of schemas to the SimpleSchema constructor or to extend()');
var schemaObj;
extend(schema = {}) {
if (Array.isArray(schema)) throw new Error('You may not pass an array of schemas to the SimpleSchema constructor or to extend()');
let schemaObj;
if (SimpleSchema.isSimpleSchema(schema)) {
schemaObj = schema._schema;
this._validators = this._validators.concat(schema._validators);
this._docValidators = this._docValidators.concat(schema._docValidators);
this._cleanOptions = (0, _extend2["default"])(false, this._cleanOptions, schema._cleanOptions);
this._constructorOptions = (0, _extend2["default"])(false, this._constructorOptions, schema._constructorOptions);
} else {
schemaObj = (0, _expandShorthand["default"])(schema);
} // Update all of the information cached on the instance
if (SimpleSchema.isSimpleSchema(schema)) {
schemaObj = schema._schema;
this._validators = this._validators.concat(schema._validators);
this._docValidators = this._docValidators.concat(schema._docValidators);
this._cleanOptions = (0, _extend.default)(false, this._cleanOptions, schema._cleanOptions);
this._constructorOptions = (0, _extend.default)(false, this._constructorOptions, schema._constructorOptions);
} else {
schemaObj = (0, _expandShorthand.default)(schema);
} // Update all of the information cached on the instance
Object.keys(schemaObj).forEach(function (fieldName) {
var definition = standardizeDefinition(schemaObj[fieldName]); // Merge/extend with any existing definition
Object.keys(schemaObj).forEach(fieldName => {
const definition = standardizeDefinition(schemaObj[fieldName]); // Merge/extend with any existing definition
if (_this8._schema[fieldName]) {
if (!_this8._schema.hasOwnProperty(fieldName)) {
// fieldName is actually a method from Object itself!
throw new Error("".concat(fieldName, " key is actually the name of a method on Object, please rename it"));
}
if (this._schema[fieldName]) {
if (!this._schema.hasOwnProperty(fieldName)) {
// fieldName is actually a method from Object itself!
throw new Error(`${fieldName} key is actually the name of a method on Object, please rename it`);
_this8._schema[fieldName] = _objectSpread({}, _this8._schema[fieldName], {}, (0, _lodash4["default"])(definition, 'type'));
if (definition.type) _this8._schema[fieldName].type.extend(definition.type);
} else {
_this8._schema[fieldName] = definition;
}
this._schema[fieldName] = _objectSpread({}, this._schema[fieldName], (0, _lodash4.default)(definition, 'type'));
if (definition.type) this._schema[fieldName].type.extend(definition.type);
} else {
this._schema[fieldName] = definition;
}
checkAndScrubDefinition(fieldName, _this8._schema[fieldName], _this8._constructorOptions, schemaObj);
});
checkSchemaOverlap(this._schema); // Set/Reset all of these
checkAndScrubDefinition(fieldName, this._schema[fieldName], this._constructorOptions, schemaObj);
});
checkSchemaOverlap(this._schema); // Set/Reset all of these
this._schemaKeys = Object.keys(this._schema);
this._autoValues = [];
this._blackboxKeys = [];
this._firstLevelSchemaKeys = [];
this._objectKeys = {}; // Update all of the information cached on the instance
this._schemaKeys = Object.keys(this._schema);
this._autoValues = [];
this._blackboxKeys = [];
this._firstLevelSchemaKeys = [];
this._objectKeys = {}; // Update all of the information cached on the instance
this._schemaKeys.forEach(function (fieldName) {
// Make sure parent has a definition in the schema. No implied objects!
if (fieldName.indexOf('.') > -1) {
var parentFieldName = fieldName.slice(0, fieldName.lastIndexOf('.'));
if (!_this8._schema.hasOwnProperty(parentFieldName)) throw new Error("\"".concat(fieldName, "\" is in the schema but \"").concat(parentFieldName, "\" is not"));
}
this._schemaKeys.forEach(fieldName => {
// Make sure parent has a definition in the schema. No implied objects!
if (fieldName.indexOf('.') > -1) {
const parentFieldName = fieldName.slice(0, fieldName.lastIndexOf('.'));
if (!this._schema.hasOwnProperty(parentFieldName)) throw new Error(`"${fieldName}" is in the schema but "${parentFieldName}" is not`);
}
var definition = _this8._schema[fieldName]; // Keep list of all top level keys
const definition = this._schema[fieldName]; // Keep list of all top level keys
if (fieldName.indexOf('.') === -1) _this8._firstLevelSchemaKeys.push(fieldName); // Keep list of all blackbox keys for passing to MongoObject constructor
// XXX For now if any oneOf type is blackbox, then the whole field is.
if (fieldName.indexOf('.') === -1) this._firstLevelSchemaKeys.push(fieldName); // Keep list of all blackbox keys for passing to MongoObject constructor
// XXX For now if any oneOf type is blackbox, then the whole field is.
(0, _lodash["default"])(definition.type.definitions, function (oneOfDef) {
if (oneOfDef.blackbox === true) {
_this8._blackboxKeys.push(fieldName);
(0, _lodash.default)(definition.type.definitions, oneOfDef => {
if (oneOfDef.blackbox === true) {
this._blackboxKeys.push(fieldName);
return false; // exit loop
}
return false; // exit loop
return true;
}); // Keep list of autoValue functions
if (typeof definition.autoValue === 'function') {
_this8._autoValues.push({
closestSubschemaFieldName: '',
fieldName: fieldName,
func: definition.autoValue
});
}
}); // Store child keys keyed by parent. This needs to be done recursively to handle
// subschemas.
return true;
}); // Keep list of autoValue functions
if (typeof definition.autoValue === 'function') {
this._autoValues.push({
closestSubschemaFieldName: '',
fieldName,
func: definition.autoValue
});
}
}); // Store child keys keyed by parent. This needs to be done recursively to handle
// subschemas.
var setObjectKeys = function setObjectKeys(curSchema, schemaParentKey) {
Object.keys(curSchema).forEach(function (fieldName) {
var definition = curSchema[fieldName];
fieldName = schemaParentKey ? "".concat(schemaParentKey, ".").concat(fieldName) : fieldName;
if (fieldName.indexOf('.') > -1 && fieldName.slice(-2) !== '.$') {
var parentKey = fieldName.slice(0, fieldName.lastIndexOf('.'));
var parentKeyWithDot = "".concat(parentKey, ".");
_this8._objectKeys[parentKeyWithDot] = _this8._objectKeys[parentKeyWithDot] || [];
const setObjectKeys = (curSchema, schemaParentKey) => {
Object.keys(curSchema).forEach(fieldName => {
const definition = curSchema[fieldName];
fieldName = schemaParentKey ? `${schemaParentKey}.${fieldName}` : fieldName;
_this8._objectKeys[parentKeyWithDot].push(fieldName.slice(fieldName.lastIndexOf('.') + 1));
} // If the current field is a nested SimpleSchema,
// iterate over the child fields and cache their properties as well
if (fieldName.indexOf('.') > -1 && fieldName.slice(-2) !== '.$') {
const parentKey = fieldName.slice(0, fieldName.lastIndexOf('.'));
const parentKeyWithDot = `${parentKey}.`;
this._objectKeys[parentKeyWithDot] = this._objectKeys[parentKeyWithDot] || [];
this._objectKeys[parentKeyWithDot].push(fieldName.slice(fieldName.lastIndexOf('.') + 1));
} // If the current field is a nested SimpleSchema,
// iterate over the child fields and cache their properties as well
definition.type.definitions.forEach(function (_ref3) {
var type = _ref3.type;
definition.type.definitions.forEach(({
type
}) => {
if (SimpleSchema.isSimpleSchema(type)) {
setObjectKeys(type._schema, fieldName);
}
if (SimpleSchema.isSimpleSchema(type)) {
setObjectKeys(type._schema, fieldName);
}
});
});
});
};
};
setObjectKeys(this._schema);
return this;
}
setObjectKeys(this._schema);
return this;
}
}, {
key: "getAllowedValuesForKey",
value: function getAllowedValuesForKey(key) {
// For array fields, `allowedValues` is on the array item definition
if (this.allowsKey("".concat(key, ".$"))) {
key = "".concat(key, ".$");
}
getAllowedValuesForKey(key) {
// For array fields, `allowedValues` is on the array item definition
if (this.allowsKey(`${key}.$`)) {
key = `${key}.$`;
var allowedValues = this.get(key, 'allowedValues');
return (0, _lodash3["default"])(allowedValues) ? null : _toConsumableArray(allowedValues);
}
}, {
key: "newContext",
value: function newContext() {
return new _ValidationContext["default"](this);
}
}, {
key: "namedContext",
value: function namedContext(name) {
if (typeof name !== 'string') name = 'default';
const allowedValues = this.get(key, 'allowedValues');
return (0, _lodash3.default)(allowedValues) ? null : [...allowedValues];
}
if (!this._validationContexts[name]) {
this._validationContexts[name] = new _ValidationContext["default"](this);
}
newContext() {
return new _ValidationContext.default(this);
}
namedContext(name) {
if (typeof name !== 'string') name = 'default';
if (!this._validationContexts[name]) {
this._validationContexts[name] = new _ValidationContext.default(this);
return this._validationContexts[name];
}
}, {
key: "addValidator",
value: function addValidator(func) {
this._validators.push(func);
}
}, {
key: "addDocValidator",
value: function addDocValidator(func) {
this._docValidators.push(func);
}
/**
* @param obj {Object|Object[]} Object or array of objects to validate.
* @param [options] {Object} Same options object that ValidationContext#validate takes
*
* Throws an Error with name `ClientError` and `details` property containing the errors.
*/
return this._validationContexts[name];
}
}, {
key: "validate",
value: function validate(obj) {
var _this9 = this;
addValidator(func) {
this._validators.push(func);
}
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
// For Meteor apps, `check` option can be passed to silence audit-argument-checks
var check = options.check || this._constructorOptions.check;
addDocValidator(func) {
this._docValidators.push(func);
}
/**
* @param obj {Object|Object[]} Object or array of objects to validate.
* @param [options] {Object} Same options object that ValidationContext#validate takes
*
* Throws an Error with name `ClientError` and `details` property containing the errors.
*/
if (typeof check === 'function') {
// Call check but ignore the error
try {
check(obj);
} catch (e) {
/* ignore error */
}
} // obj can be an array, in which case we validate each object in it and
// throw as soon as one has an error
validate(obj, options = {}) {
// For Meteor apps, `check` option can be passed to silence audit-argument-checks
const check = options.check || this._constructorOptions.check;
var objects = Array.isArray(obj) ? obj : [obj];
objects.forEach(function (oneObj) {
var validationContext = _this9.newContext();
if (typeof check === 'function') {
// Call check but ignore the error
try {
check(obj);
} catch (e) {
/* ignore error */
}
} // obj can be an array, in which case we validate each object in it and
// throw as soon as one has an error
var isValid = validationContext.validate(oneObj, options);
if (isValid) return;
var errors = validationContext.validationErrors(); // In order for the message at the top of the stack trace to be useful,
// we set it to the first validation error message.
var message = _this9.messageForError(errors[0]);
const objects = Array.isArray(obj) ? obj : [obj];
objects.forEach(oneObj => {
const validationContext = this.newContext();
const isValid = validationContext.validate(oneObj, options);
if (isValid) return;
const errors = validationContext.validationErrors(); // In order for the message at the top of the stack trace to be useful,
// we set it to the first validation error message.
var error = new Error(message);
error.name = error.errorType = 'ClientError';
error.error = 'validation-error'; // Add meaningful error messages for each validation error.
// Useful for display messages when using 'mdg:validated-method'.
const message = this.messageForError(errors[0]);
const error = new Error(message);
error.name = error.errorType = 'ClientError';
error.error = 'validation-error'; // Add meaningful error messages for each validation error.
// Useful for display messages when using 'mdg:validated-method'.
error.details = errors.map(function (errorDetail) {
return _objectSpread({}, errorDetail, {
message: _this9.messageForError(errorDetail)
});
}); // The primary use for the validationErrorTransform is to convert the
// vanilla Error into a Meteor.Error until DDP is able to pass
// vanilla errors back to the client.
error.details = errors.map(errorDetail => _objectSpread({}, errorDetail, {
message: this.messageForError(errorDetail)
})); // The primary use for the validationErrorTransform is to convert the
// vanilla Error into a Meteor.Error until DDP is able to pass
// vanilla errors back to the client.
if (typeof SimpleSchema.validationErrorTransform === 'function') {
throw SimpleSchema.validationErrorTransform(error);
} else {
throw error;
}
});
}
/**
* @param obj {Object} Object to validate.
* @param [options] {Object} Same options object that ValidationContext#validate takes
*
* Returns a Promise that resolves with the errors
*/
if (typeof SimpleSchema.validationErrorTransform === 'function') {
throw SimpleSchema.validationErrorTransform(error);
} else {
throw error;
}
});
}
/**
* @param obj {Object} Object to validate.
* @param [options] {Object} Same options object that ValidationContext#validate takes
*
* Returns a Promise that resolves with the errors
*/
}, {
key: "validateAndReturnErrorsPromise",
value: function validateAndReturnErrorsPromise(obj, options) {
var _this10 = this;
var validationContext = this.newContext();
var isValid = validationContext.validate(obj, options);
if (isValid) return Promise.resolve([]); // Add the `message` prop
validateAndReturnErrorsPromise(obj, options) {
const validationContext = this.newContext();
const isValid = validationContext.validate(obj, options);
if (isValid) return Promise.resolve([]); // Add the `message` prop
const errors = validationContext.validationErrors().map(errorDetail => {
return _objectSpread({}, errorDetail, {
message: this.messageForError(errorDetail)
var errors = validationContext.validationErrors().map(function (errorDetail) {
return _objectSpread({}, errorDetail, {
message: _this10.messageForError(errorDetail)
});
});
});
return Promise.resolve(errors);
}
return Promise.resolve(errors);
}
}, {
key: "validator",
value: function validator() {
var _this11 = this;
validator(options = {}) {
return obj => {
const optionsClone = _objectSpread({}, options);
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return function (obj) {
var optionsClone = _objectSpread({}, options);
if (options.clean === true) {
// Do this here and pass into both functions for better performance
optionsClone.mongoObject = new _mongoObject.default(obj, this.blackboxKeys());
this.clean(obj, optionsClone);
}
if (options.clean === true) {
// Do this here and pass into both functions for better performance
optionsClone.mongoObject = new _mongoObject["default"](obj, _this11.blackboxKeys());
if (options.returnErrorsPromise) {
return this.validateAndReturnErrorsPromise(obj, optionsClone);
}
_this11.clean(obj, optionsClone);
}
return this.validate(obj, optionsClone);
};
}
if (options.returnErrorsPromise) {
return _this11.validateAndReturnErrorsPromise(obj, optionsClone);
}
getFormValidator(options = {}) {
return this.validator(_objectSpread({}, options, {
returnErrorsPromise: true
}));
}
return _this11.validate(obj, optionsClone);
};
}
}, {
key: "getFormValidator",
value: function getFormValidator() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return this.validator(_objectSpread({}, options, {
returnErrorsPromise: true
}));
}
}, {
key: "clean",
value: function clean() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
clean(...args) {
return (0, _clean.default)(this, ...args);
}
/**
* Change schema labels on the fly, causing mySchema.label computation
* to rerun. Useful when the user changes the language.
*
* @param {Object} labels A dictionary of all the new label values, by schema key.
*/
return _clean2["default"].apply(void 0, [this].concat(args));
}
/**
* Change schema labels on the fly, causing mySchema.label computation
* to rerun. Useful when the user changes the language.
*
* @param {Object} labels A dictionary of all the new label values, by schema key.
*/
}, {
key: "labels",
value: function labels(_labels) {
var _this12 = this;
labels(labels) {
Object.keys(labels).forEach(key => {
const label = labels[key];
if (typeof label !== 'string' && typeof label !== 'function') return;
if (!this._schema.hasOwnProperty(key)) return;
this._schema[key].label = label;
this._depsLabels[key] && this._depsLabels[key].changed();
});
}
/**
* Gets a field's label or all field labels reactively.
*
* @param {String} [key] The schema key, specific or generic.
* Omit this argument to get a dictionary of all labels.
* @returns {String} The label
*/
label(key) {
// Get all labels
if (key === null || key === undefined) {
const result = {};
this._schemaKeys.forEach(schemaKey => {
result[schemaKey] = this.label(schemaKey);
Object.keys(_labels).forEach(function (key) {
var label = _labels[key];
if (typeof label !== 'string' && typeof label !== 'function') return;
if (!_this12._schema.hasOwnProperty(key)) return;
_this12._schema[key].label = label;
_this12._depsLabels[key] && _this12._depsLabels[key].changed();
});
}
/**
* Gets a field's label or all field labels reactively.
*
* @param {String} [key] The schema key, specific or generic.
* Omit this argument to get a dictionary of all labels.
* @returns {String} The label
*/
return result;
} // Get label for one field
}, {
key: "label",
value: function label(key) {
var _this13 = this;
// Get all labels
if (key === null || key === undefined) {
var result = {};
const label = this.get(key, 'label');
if (label) this.reactiveLabelDependency(key);
return label || null;
}
/**
* Gets a field's property
*
* @param {String} key The schema key, specific or generic.
* @param {String} prop Name of the property to get for that schema key
* @param {Object} [functionContext] The `this` context to use if prop is a function
* @returns {any} The property value
*/
this._schemaKeys.forEach(function (schemaKey) {
result[schemaKey] = _this13.label(schemaKey);
});
return result;
} // Get label for one field
get(key, prop, functionContext) {
const def = this.getDefinition(key, ['type', prop], functionContext);
if (!def) return undefined;
if ((0, _lodash2.default)(schemaDefinitionOptions, prop)) {
return def[prop];
var label = this.get(key, 'label');
if (label) this.reactiveLabelDependency(key);
return label || null;
}
/**
* Gets a field's property
*
* @param {String} key The schema key, specific or generic.
* @param {String} prop Name of the property to get for that schema key
* @param {Object} [functionContext] The `this` context to use if prop is a function
* @returns {any} The property value
*/
return (def.type.find(props => props[prop]) || {})[prop];
} // shorthand for getting defaultValue
}, {
key: "get",
value: function get(key, prop, functionContext) {
var def = this.getDefinition(key, ['type', prop], functionContext);
if (!def) return undefined;
defaultValue(key) {
return this.get(key, 'defaultValue');
} // Returns a string message for the given error type and key. Passes through
// to message-box pkg.
messageForError(errorInfo) {
const {
name
} = errorInfo;
return this.messageBox.message(errorInfo, {
context: {
key: name,
// backward compatibility
// The call to this.label() establishes a reactive dependency, too
label: this.label(name)
if ((0, _lodash2["default"])(schemaDefinitionOptions, prop)) {
return def[prop];
}
});
}
/**
* @method SimpleSchema#pick
* @param {[fields]} The list of fields to pick to instantiate the subschema
* @returns {SimpleSchema} The subschema
*/
return (def.type.find(function (props) {
return props[prop];
}) || {})[prop];
} // shorthand for getting defaultValue
// If you need to allow properties other than those listed above, call this from your app or package
static extendOptions(options) {
// For backwards compatibility we still take an object here, but we only care about the names
if (!Array.isArray(options)) options = Object.keys(options);
options.forEach(option => {
schemaDefinitionOptions.push(option);
});
}
}, {
key: "defaultValue",
value: function defaultValue(key) {
return this.get(key, 'defaultValue');
} // Returns a string message for the given error type and key. Passes through
// to message-box pkg.
static defineValidationErrorTransform(transform) {
if (typeof transform !== 'function') {
throw new Error('SimpleSchema.defineValidationErrorTransform must be passed a function that accepts an Error and returns an Error');
}, {
key: "messageForError",
value: function messageForError(errorInfo) {
var name = errorInfo.name;
return this.messageBox.message(errorInfo, {
context: {
key: name,
// backward compatibility
// The call to this.label() establishes a reactive dependency, too
label: this.label(name)
}
});
}
/**
* @method SimpleSchema#pick
* @param {[fields]} The list of fields to pick to instantiate the subschema
* @returns {SimpleSchema} The subschema
*/
SimpleSchema.validationErrorTransform = transform;
}
}], [{
key: "isSimpleSchema",
value: function isSimpleSchema(obj) {
return obj && (obj instanceof SimpleSchema || obj._schema);
}
}, {
key: "extendOptions",
// If you need to allow properties other than those listed above, call this from your app or package
value: function extendOptions(options) {
// For backwards compatibility we still take an object here, but we only care about the names
if (!Array.isArray(options)) options = Object.keys(options);
options.forEach(function (option) {
schemaDefinitionOptions.push(option);
});
}
}, {
key: "defineValidationErrorTransform",
value: function defineValidationErrorTransform(transform) {
if (typeof transform !== 'function') {
throw new Error('SimpleSchema.defineValidationErrorTransform must be passed a function that accepts an Error and returns an Error');
}
static validate(obj, schema, options) {
// Allow passing just the schema object
if (!SimpleSchema.isSimpleSchema(schema)) {
schema = new SimpleSchema(schema);
SimpleSchema.validationErrorTransform = transform;
}
}, {
key: "validate",
value: function validate(obj, schema, options) {
// Allow passing just the schema object
if (!SimpleSchema.isSimpleSchema(schema)) {
schema = new SimpleSchema(schema);
}
return schema.validate(obj, options);
}
return schema.validate(obj, options);
}
}, {
key: "oneOf",
value: function oneOf() {
for (var _len2 = arguments.length, definitions = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
definitions[_key2] = arguments[_key2];
}
static oneOf(...definitions) {
return new _SimpleSchemaGroup.default(...definitions);
}
return _construct(_SimpleSchemaGroup["default"], definitions);
}
}, {
key: "addValidator",
value: function addValidator(func) {
SimpleSchema._validators.push(func);
}
}, {
key: "addDocValidator",
value: function addDocValidator(func) {
SimpleSchema._docValidators.push(func);
}
}]);
static addValidator(func) {
SimpleSchema._validators.push(func);
}
static addDocValidator(func) {
SimpleSchema._docValidators.push(func);
}
}
return SimpleSchema;
}();
/*

@@ -848,3 +965,3 @@ * PRIVATE

_defineProperty(SimpleSchema, "RegEx", _regExp.default);
_defineProperty(SimpleSchema, "RegEx", _regExp["default"]);

@@ -877,21 +994,21 @@ _defineProperty(SimpleSchema, "_validators", []);

_defineProperty(SimpleSchema, "_makeGeneric", _mongoObject.default.makeKeyGeneric);
_defineProperty(SimpleSchema, "_makeGeneric", _mongoObject["default"].makeKeyGeneric);
_defineProperty(SimpleSchema, "ValidationContext", _ValidationContext.default);
_defineProperty(SimpleSchema, "ValidationContext", _ValidationContext["default"]);
_defineProperty(SimpleSchema, "setDefaultMessages", messages => {
(0, _extend.default)(true, _defaultMessages.default, messages);
_defineProperty(SimpleSchema, "setDefaultMessages", function (messages) {
(0, _extend2["default"])(true, _defaultMessages["default"], messages);
});
function checkSchemaOverlap(schema) {
Object.keys(schema).forEach(key => {
const val = schema[key];
if (!val.type) throw new Error(`${key} key is missing "type"`);
val.type.definitions.forEach(def => {
Object.keys(schema).forEach(function (key) {
var val = schema[key];
if (!val.type) throw new Error("".concat(key, " key is missing \"type\""));
val.type.definitions.forEach(function (def) {
if (!SimpleSchema.isSimpleSchema(def.type)) return;
Object.keys(def.type._schema).forEach(subKey => {
const newKey = `${key}.${subKey}`;
Object.keys(def.type._schema).forEach(function (subKey) {
var newKey = "".concat(key, ".").concat(subKey);
if (schema.hasOwnProperty(newKey)) {
throw new Error(`The type for "${key}" is set to a SimpleSchema instance that defines "${key}.${subKey}", but the parent SimpleSchema instance also tries to define "${key}.${subKey}"`);
throw new Error("The type for \"".concat(key, "\" is set to a SimpleSchema instance that defines \"").concat(key, ".").concat(subKey, "\", but the parent SimpleSchema instance also tries to define \"").concat(key, ".").concat(subKey, "\""));
}

@@ -910,4 +1027,4 @@ });

function inflectedLabel(fieldName, shouldHumanize) {
const pieces = fieldName.split('.');
let label;
var pieces = fieldName.split('.');
var label;

@@ -918,3 +1035,3 @@ do {

return shouldHumanize ? (0, _humanize.default)(label) : label;
return shouldHumanize ? (0, _humanize["default"])(label) : label;
}

@@ -943,11 +1060,11 @@

function standardizeDefinition(def) {
const standardizedDef = (0, _lodash4.default)(def, oneOfProps); // Internally, all definition types are stored as groups for simplicity of access.
var standardizedDef = (0, _lodash4["default"])(def, oneOfProps); // Internally, all definition types are stored as groups for simplicity of access.
// If we are extending, there may not actually be def.type, but it's okay because
// it will be added later when the two SimpleSchemaGroups are merged.
if (def.type && def.type instanceof _SimpleSchemaGroup.default) {
if (def.type && def.type instanceof _SimpleSchemaGroup["default"]) {
standardizedDef.type = def.type.clone();
} else {
const groupProps = (0, _lodash5.default)(def, oneOfProps);
standardizedDef.type = new _SimpleSchemaGroup.default(groupProps);
var groupProps = (0, _lodash5["default"])(def, oneOfProps);
standardizedDef.type = new _SimpleSchemaGroup["default"](groupProps);
}

@@ -960,22 +1077,21 @@

function checkAndScrubDefinition(fieldName, definition, options, fullSchemaObj) {
if (!definition.type) throw new Error(`${fieldName} key is missing "type"`); // Validate the field definition
if (!definition.type) throw new Error("".concat(fieldName, " key is missing \"type\"")); // Validate the field definition
Object.keys(definition).forEach(key => {
Object.keys(definition).forEach(function (key) {
if (schemaDefinitionOptions.indexOf(key) === -1) {
throw new Error(`Invalid definition for ${fieldName} field: "${key}" is not a supported property`);
throw new Error("Invalid definition for ".concat(fieldName, " field: \"").concat(key, "\" is not a supported property"));
}
}); // Make sure the `type`s are OK
let couldBeArray = false;
definition.type.definitions.forEach(({
type
}) => {
if (!type) throw new Error(`Invalid definition for ${fieldName} field: "type" option is required`);
var couldBeArray = false;
definition.type.definitions.forEach(function (_ref4) {
var type = _ref4.type;
if (!type) throw new Error("Invalid definition for ".concat(fieldName, " field: \"type\" option is required"));
if (Array.isArray(type)) {
throw new Error(`Invalid definition for ${fieldName} field: "type" may not be an array. Change it to Array.`);
throw new Error("Invalid definition for ".concat(fieldName, " field: \"type\" may not be an array. Change it to Array."));
}
if (type.constructor === Object && (0, _lodash3.default)(type)) {
throw new Error(`Invalid definition for ${fieldName} field: "type" may not be an object. Change it to Object`);
if (type.constructor === Object && (0, _lodash3["default"])(type)) {
throw new Error("Invalid definition for ".concat(fieldName, " field: \"type\" may not be an object. Change it to Object"));
}

@@ -986,7 +1102,7 @@

if (SimpleSchema.isSimpleSchema(type)) {
Object.keys(type._schema).forEach(subKey => {
const newKey = `${fieldName}.${subKey}`;
Object.keys(type._schema).forEach(function (subKey) {
var newKey = "".concat(fieldName, ".").concat(subKey);
if (fullSchemaObj.hasOwnProperty(newKey)) {
throw new Error(`The type for "${fieldName}" is set to a SimpleSchema instance that defines "${newKey}", but the parent SimpleSchema instance also tries to define "${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, "\""));
}

@@ -998,4 +1114,4 @@ });

if (couldBeArray && !fullSchemaObj.hasOwnProperty(`${fieldName}.$`)) {
throw new Error(`"${fieldName}" is Array type but the schema does not include a "${fieldName}.$" definition for the array items"`);
if (couldBeArray && !fullSchemaObj.hasOwnProperty("".concat(fieldName, ".$"))) {
throw new Error("\"".concat(fieldName, "\" is Array type but the schema does not include a \"").concat(fieldName, ".$\" definition for the array items\""));
} // defaultValue -> autoValue

@@ -1008,3 +1124,3 @@ // We support defaultValue shortcut by converting it immediately into an

if ('autoValue' in definition && !definition.autoValue.isDefault) {
console.warn(`SimpleSchema: Found both autoValue and defaultValue options for "${fieldName}". Ignoring defaultValue.`);
console.warn("SimpleSchema: Found both autoValue and defaultValue options for \"".concat(fieldName, "\". Ignoring defaultValue."));
} else {

@@ -1027,3 +1143,7 @@ if (fieldName.endsWith('.$')) {

if (typeof definition.required === 'function') {
definition.optional = function optional(...args) {
definition.optional = function optional() {
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
return !definition.required.apply(this, args);

@@ -1054,13 +1174,21 @@ };

function getPickOrOmit(type) {
return function pickOrOmit(...args) {
return function pickOrOmit() {
var _this14 = this;
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
args[_key4] = arguments[_key4];
}
// If they are picking/omitting an object or array field, we need to also include everything under it
const newSchema = {};
var newSchema = {};
this._schemaKeys.forEach(key => {
this._schemaKeys.forEach(function (key) {
// Pick/omit it if it IS in the array of keys they want OR if it
// STARTS WITH something that is in the array plus a period
const includeIt = args.some(wantedField => key === wantedField || key.indexOf(`${wantedField}.`) === 0);
var includeIt = args.some(function (wantedField) {
return key === wantedField || key.indexOf("".concat(wantedField, ".")) === 0;
});
if (includeIt && type === 'pick' || !includeIt && type === 'omit') {
newSchema[key] = this._schema[key];
newSchema[key] = _this14._schema[key];
}

@@ -1067,0 +1195,0 @@ });

@@ -13,19 +13,32 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
/* eslint-disable func-names, prefer-arrow-callback */
class CustomObject {
constructor(obj) {
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var CustomObject =
/*#__PURE__*/
function () {
function CustomObject(obj) {
_classCallCheck(this, CustomObject);
Object.assign(this, obj);
}
bar() {
return 20;
}
_createClass(CustomObject, [{
key: "bar",
value: function bar() {
return 20;
}
}]);
}
return CustomObject;
}();
describe('SimpleSchema', function () {
it('throws error if first argument is an array', function () {
(0, _expect.default)(function () {
(0, _expect["default"])(function () {
return new _SimpleSchema.SimpleSchema([]);

@@ -35,3 +48,3 @@ }).toThrow('You may not pass an array of schemas to the SimpleSchema constructor or to extend()');

it('throws error if a key is missing type', function () {
(0, _expect.default)(function () {
(0, _expect["default"])(function () {
return new _SimpleSchema.SimpleSchema({

@@ -43,3 +56,3 @@ foo: {}

it('throws an explicit error if you define fields that override object methods', function () {
(0, _expect.default)(function () {
(0, _expect["default"])(function () {
return new _SimpleSchema.SimpleSchema({

@@ -53,3 +66,3 @@ valueOf: {

it('throws a error if array item definition is missing', function () {
(0, _expect.default)(function () {
(0, _expect["default"])(function () {
return new _SimpleSchema.SimpleSchema({

@@ -62,3 +75,3 @@ someArray: Array

it('throws an error if a nested schema defines a field that its parent also defines', function () {
(0, _expect.default)(function () {
(0, _expect["default"])(function () {
return new _SimpleSchema.SimpleSchema({

@@ -73,3 +86,3 @@ foo: new _SimpleSchema.SimpleSchema({

it('expects a field with SimpleSchema type to be an object', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: new _SimpleSchema.SimpleSchema({

@@ -79,7 +92,7 @@ bar: String

});
const context = schema.newContext();
var context = schema.newContext();
context.validate({
foo: 'string'
});
(0, _expect.default)(context.validationErrors()).toEqual([{
(0, _expect["default"])(context.validationErrors()).toEqual([{
dataType: 'Object',

@@ -92,3 +105,3 @@ name: 'foo',

it('includes type validation errors from nested schemas', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: new _SimpleSchema.SimpleSchema({

@@ -98,3 +111,3 @@ bar: String

});
const context = schema.newContext();
var context = schema.newContext();
context.validate({

@@ -105,3 +118,3 @@ foo: {

});
(0, _expect.default)(context.validationErrors()).toEqual([{
(0, _expect["default"])(context.validationErrors()).toEqual([{
dataType: 'String',

@@ -114,3 +127,3 @@ name: 'foo.bar',

it('includes allowed value validation errors from nested schemas', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: new _SimpleSchema.SimpleSchema({

@@ -123,3 +136,3 @@ bar: {

});
const context = schema.newContext();
var context = schema.newContext();
context.validate({

@@ -130,3 +143,3 @@ foo: {

});
(0, _expect.default)(context.validationErrors()).toEqual([{
(0, _expect["default"])(context.validationErrors()).toEqual([{
name: 'foo.bar',

@@ -138,3 +151,3 @@ type: _SimpleSchema.SimpleSchema.ErrorTypes.VALUE_NOT_ALLOWED,

it('includes validation errors from nested schemas when validating modifiers', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: new _SimpleSchema.SimpleSchema({

@@ -144,3 +157,3 @@ bar: String

});
const context = schema.newContext();
var context = schema.newContext();
context.validate({

@@ -153,3 +166,3 @@ $set: {

});
(0, _expect.default)(context.validationErrors()).toEqual([{
(0, _expect["default"])(context.validationErrors()).toEqual([{
dataType: 'String',

@@ -162,3 +175,3 @@ name: 'foo.bar',

it('validates nested requiredness', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
a: {

@@ -176,7 +189,7 @@ type: new _SimpleSchema.SimpleSchema({

});
let context = schema.newContext();
var context = schema.newContext();
context.validate({
a: {}
});
(0, _expect.default)(context.validationErrors()).toEqual([{
(0, _expect["default"])(context.validationErrors()).toEqual([{
name: 'a.b',

@@ -196,3 +209,3 @@ type: _SimpleSchema.SimpleSchema.ErrorTypes.REQUIRED,

});
(0, _expect.default)(context.validationErrors()).toEqual([{
(0, _expect["default"])(context.validationErrors()).toEqual([{
name: 'a.b.c',

@@ -204,5 +217,5 @@ type: _SimpleSchema.SimpleSchema.ErrorTypes.REQUIRED,

it('issue #307 - throws an error if incorrect import results in empty object', function () {
(0, _expect.default)(function () {
(0, _expect["default"])(function () {
// Assume that default import of a file with no default export returns an empty object
const Place = {}; // eslint-disable-next-line no-new
var Place = {}; // eslint-disable-next-line no-new

@@ -223,3 +236,3 @@ new _SimpleSchema.SimpleSchema({

it('Safely sets defaultValues on subschemas nested in arrays', function () {
const nestedSchema = new _SimpleSchema.SimpleSchema({
var nestedSchema = new _SimpleSchema.SimpleSchema({
nested: {

@@ -242,4 +255,4 @@ type: Array

});
const context = nestedSchema.newContext();
const cleaned = context.clean({
var context = nestedSchema.newContext();
var cleaned = context.clean({
$set: {

@@ -255,3 +268,3 @@ nested: [{

});
(0, _expect.default)(cleaned).toEqual({
(0, _expect["default"])(cleaned).toEqual({
$set: {

@@ -270,3 +283,3 @@ nested: [{

// With $set
const userSchema = new _SimpleSchema.SimpleSchema({
var userSchema = new _SimpleSchema.SimpleSchema({
profile: {

@@ -279,4 +292,4 @@ type: Object

});
const context = userSchema.namedContext();
(0, _expect.default)(context.validate({
var context = userSchema.namedContext();
(0, _expect["default"])(context.validate({
$set: {

@@ -289,3 +302,3 @@ profile: {}

const userSchema2 = new _SimpleSchema.SimpleSchema({
var userSchema2 = new _SimpleSchema.SimpleSchema({
profile: {

@@ -301,4 +314,4 @@ type: Array

});
const context2 = userSchema2.namedContext();
(0, _expect.default)(context2.validate({
var context2 = userSchema2.namedContext();
(0, _expect["default"])(context2.validate({
$push: {

@@ -312,3 +325,3 @@ profile: {}

it('validate object with prototype', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -318,31 +331,31 @@ type: _SimpleSchema.SimpleSchema.Integer

});
const testObj = new CustomObject({
var testObj = new CustomObject({
foo: 1
});
const context = schema.namedContext();
(0, _expect.default)(context.validate(testObj)).toBe(true);
(0, _expect.default)(testObj instanceof CustomObject).toBe(true);
var context = schema.namedContext();
(0, _expect["default"])(context.validate(testObj)).toBe(true);
(0, _expect["default"])(testObj instanceof CustomObject).toBe(true);
testObj.foo = 'not a number';
(0, _expect.default)(context.validate(testObj)).toBe(false);
(0, _expect["default"])(context.validate(testObj)).toBe(false);
});
it('validate object with prototype within normal object', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
customObject: Object,
'customObject.foo': _SimpleSchema.SimpleSchema.Integer
});
const customObject = new CustomObject({
var customObject = new CustomObject({
foo: 1
});
const testObj = {
customObject
var testObj = {
customObject: customObject
};
const context = schema.namedContext();
(0, _expect.default)(context.validate(testObj)).toBe(true);
(0, _expect.default)(testObj.customObject instanceof CustomObject).toBe(true);
var context = schema.namedContext();
(0, _expect["default"])(context.validate(testObj)).toBe(true);
(0, _expect["default"])(testObj.customObject instanceof CustomObject).toBe(true);
testObj.customObject.foo = 'not a number';
(0, _expect.default)(context.validate(testObj)).toBe(false);
(0, _expect["default"])(context.validate(testObj)).toBe(false);
});
it('allowsKey', function () {
function run(key, allowed) {
(0, _expect.default)(_testSchema.default.allowsKey(key)).toBe(allowed);
(0, _expect["default"])(_testSchema["default"].allowsKey(key)).toBe(allowed);
}

@@ -380,3 +393,3 @@

it('allowsKey in subschema', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: new _SimpleSchema.SimpleSchema({

@@ -387,9 +400,9 @@ bar: Object,

});
(0, _expect.default)(schema.allowsKey('foo.bar')).toBe(true);
(0, _expect.default)(schema.allowsKey('foo.bar.baz')).toBe(true);
(0, _expect.default)(schema.allowsKey('foo.bar.bum')).toBe(false);
(0, _expect.default)(schema.allowsKey('foo.bar.baz.bum')).toBe(false);
(0, _expect["default"])(schema.allowsKey('foo.bar')).toBe(true);
(0, _expect["default"])(schema.allowsKey('foo.bar.baz')).toBe(true);
(0, _expect["default"])(schema.allowsKey('foo.bar.bum')).toBe(false);
(0, _expect["default"])(schema.allowsKey('foo.bar.baz.bum')).toBe(false);
});
it('validating an object with a "length" property should not error', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
length: {

@@ -400,3 +413,3 @@ type: Number,

});
(0, _expect.default)(() => {
(0, _expect["default"])(function () {
schema.validate({

@@ -415,3 +428,3 @@ length: 10

it('extend with no type', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
name: {

@@ -427,25 +440,21 @@ type: String,

});
(0, _expect.default)(schema.get('name', 'max')).toBe(15);
(0, _expect["default"])(schema.get('name', 'max')).toBe(15);
});
it('this.key in label function context', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
items: Array,
'items.$': {
type: String,
label() {
const {
key
} = this;
label: function label() {
var key = this.key;
if (!key) return 'Item';
return `Item ${key.slice(key.lastIndexOf('.') + 1)}`;
return "Item ".concat(key.slice(key.lastIndexOf('.') + 1));
}
}
});
(0, _expect.default)(schema.label('items.0')).toBe('Item 0');
(0, _expect.default)(schema.label('items.1')).toBe('Item 1');
(0, _expect["default"])(schema.label('items.0')).toBe('Item 0');
(0, _expect["default"])(schema.label('items.1')).toBe('Item 1');
});
it('keyIsInBlackBox in subschema', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: new _SimpleSchema.SimpleSchema({

@@ -458,9 +467,9 @@ bar: {

});
(0, _expect.default)(schema.keyIsInBlackBox('foo.bar')).toBe(false);
(0, _expect.default)(schema.keyIsInBlackBox('foo.bar.baz')).toBe(true);
(0, _expect.default)(schema.keyIsInBlackBox('foo.bar.baz.$.bum')).toBe(true);
(0, _expect["default"])(schema.keyIsInBlackBox('foo.bar')).toBe(false);
(0, _expect["default"])(schema.keyIsInBlackBox('foo.bar.baz')).toBe(true);
(0, _expect["default"])(schema.keyIsInBlackBox('foo.bar.baz.$.bum')).toBe(true);
});
describe('blackboxKeys from subschema', function () {
it('are correct', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
apple: {

@@ -477,6 +486,6 @@ type: Object,

});
(0, _expect.default)(schema.blackboxKeys()).toEqual(['apple', 'pear.info']);
(0, _expect["default"])(schema.blackboxKeys()).toEqual(['apple', 'pear.info']);
});
it('are updated after extending', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
apple: {

@@ -496,3 +505,3 @@ type: Object,

});
(0, _expect.default)(schema.blackboxKeys()).toEqual(['apple']);
(0, _expect["default"])(schema.blackboxKeys()).toEqual(['apple']);
});

@@ -502,3 +511,3 @@ });

it('works for plain object', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
firstName: {

@@ -520,3 +529,3 @@ type: String,

});
(0, _expect.default)(schema.schema()).toEqual({
(0, _expect["default"])(schema.schema()).toEqual({
firstName: {

@@ -535,3 +544,3 @@ type: _SimpleSchema.SimpleSchema.oneOf(String),

it('works for another SimpleSchema instance and copies validators', function () {
const schema1 = new _SimpleSchema.SimpleSchema({
var schema1 = new _SimpleSchema.SimpleSchema({
firstName: {

@@ -548,3 +557,3 @@ type: String,

});
const schema2 = new _SimpleSchema.SimpleSchema({
var schema2 = new _SimpleSchema.SimpleSchema({
age: {

@@ -555,5 +564,5 @@ type: Number,

});
schema2.addValidator(() => {});
schema2.addDocValidator(() => {});
(0, _expect.default)(schema1.schema()).toEqual({
schema2.addValidator(function () {});
schema2.addDocValidator(function () {});
(0, _expect["default"])(schema1.schema()).toEqual({
firstName: {

@@ -570,6 +579,6 @@ type: _SimpleSchema.SimpleSchema.oneOf(String),

});
(0, _expect.default)(schema1._validators.length).toBe(0);
(0, _expect.default)(schema1._docValidators.length).toBe(0);
(0, _expect["default"])(schema1._validators.length).toBe(0);
(0, _expect["default"])(schema1._docValidators.length).toBe(0);
schema1.extend(schema2);
(0, _expect.default)(schema1.schema()).toEqual({
(0, _expect["default"])(schema1.schema()).toEqual({
firstName: {

@@ -591,7 +600,7 @@ type: _SimpleSchema.SimpleSchema.oneOf(String),

});
(0, _expect.default)(schema1._validators.length).toBe(1);
(0, _expect.default)(schema1._docValidators.length).toBe(1);
(0, _expect["default"])(schema1._validators.length).toBe(1);
(0, _expect["default"])(schema1._docValidators.length).toBe(1);
});
it('keeps both min and max', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
name: {

@@ -608,17 +617,17 @@ type: String,

});
(0, _expect.default)(schema._schema.name.type.definitions[0].min).toBe(5);
(0, _expect.default)(schema._schema.name.type.definitions[0].max).toBe(15);
(0, _expect["default"])(schema._schema.name.type.definitions[0].min).toBe(5);
(0, _expect["default"])(schema._schema.name.type.definitions[0].max).toBe(15);
});
it('does not mutate a schema that is passed to extend', function () {
const itemSchema = new _SimpleSchema.SimpleSchema({
var itemSchema = new _SimpleSchema.SimpleSchema({
_id: String
});
const mainSchema = new _SimpleSchema.SimpleSchema({
var mainSchema = new _SimpleSchema.SimpleSchema({
items: Array,
'items.$': itemSchema
});
const item2Schema = new _SimpleSchema.SimpleSchema({
var item2Schema = new _SimpleSchema.SimpleSchema({
blah: String
});
const main2Schema = new _SimpleSchema.SimpleSchema({
var main2Schema = new _SimpleSchema.SimpleSchema({
items: Array,

@@ -628,7 +637,7 @@ 'items.$': item2Schema

new _SimpleSchema.SimpleSchema({}).extend(mainSchema).extend(main2Schema);
(0, _expect.default)(mainSchema._schema['items.$'].type.definitions[0].type._schemaKeys).toEqual(['_id']);
(0, _expect["default"])(mainSchema._schema['items.$'].type.definitions[0].type._schemaKeys).toEqual(['_id']);
});
});
it('empty required array is valid', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
names: {

@@ -641,3 +650,3 @@ type: Array

});
(0, _expectValid.default)(schema, {
(0, _expectValid["default"])(schema, {
names: []

@@ -647,3 +656,3 @@ });

it('null in array is not valid', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
names: {

@@ -656,3 +665,3 @@ type: Array

});
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, schema, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, schema, {
names: [null]

@@ -662,3 +671,3 @@ });

it('null is valid for optional', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
test: {

@@ -669,3 +678,3 @@ type: String,

});
(0, _expectValid.default)(schema, {
(0, _expectValid["default"])(schema, {
test: null

@@ -675,3 +684,3 @@ });

it('issue 360', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
emails: {

@@ -691,3 +700,3 @@ type: Array

});
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, schema, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, schema, {
emails: [{

@@ -700,3 +709,3 @@ address: 12321,

}).toBe(2);
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, schema, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE, schema, {
emails: [{

@@ -711,3 +720,3 @@ address: 12321,

it('ignore option', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
foo: {

@@ -718,6 +727,6 @@ type: String,

});
(0, _expectValid.default)(schema, {
(0, _expectValid["default"])(schema, {
foo: 'bar'
});
(0, _expectValid.default)(schema, {
(0, _expectValid["default"])(schema, {
foo: 'bar'

@@ -727,3 +736,3 @@ }, {

});
(0, _expectValid.default)(schema, {
(0, _expectValid["default"])(schema, {
foo: 'bar'

@@ -734,6 +743,6 @@ }, {

});
(0, _expectErrorOfTypeLength.default)(_SimpleSchema.SimpleSchema.ErrorTypes.KEY_NOT_IN_SCHEMA, schema, {
(0, _expectErrorOfTypeLength["default"])(_SimpleSchema.SimpleSchema.ErrorTypes.KEY_NOT_IN_SCHEMA, schema, {
bar: 'foo'
});
(0, _expectValid.default)(schema, {
(0, _expectValid["default"])(schema, {
bar: 'foo'

@@ -743,3 +752,3 @@ }, {

});
(0, _expectValid.default)(schema, {
(0, _expectValid["default"])(schema, {
bar: 'foo'

@@ -752,4 +761,4 @@ }, {

it('ClientError', function () {
const schema = new _SimpleSchema.SimpleSchema({
int: _SimpleSchema.SimpleSchema.Integer,
var schema = new _SimpleSchema.SimpleSchema({
"int": _SimpleSchema.SimpleSchema.Integer,
string: String

@@ -759,16 +768,16 @@ });

function verify(error) {
(0, _expect.default)(error.name).toBe('ClientError');
(0, _expect.default)(error.errorType).toBe('ClientError');
(0, _expect.default)(error.error).toBe('validation-error');
(0, _expect.default)(error.details.length).toBe(2);
(0, _expect.default)(error.details[0].name).toBe('int');
(0, _expect.default)(error.details[0].type).toBe(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE);
(0, _expect.default)(error.details[0].message).toBe('Int must be of type Integer');
(0, _expect.default)(error.details[1].name).toBe('string');
(0, _expect.default)(error.details[1].type).toBe(_SimpleSchema.SimpleSchema.ErrorTypes.REQUIRED);
(0, _expect.default)(error.details[1].message).toBe('String is required'); // In order for the message at the top of the stack trace to be useful,
(0, _expect["default"])(error.name).toBe('ClientError');
(0, _expect["default"])(error.errorType).toBe('ClientError');
(0, _expect["default"])(error.error).toBe('validation-error');
(0, _expect["default"])(error.details.length).toBe(2);
(0, _expect["default"])(error.details[0].name).toBe('int');
(0, _expect["default"])(error.details[0].type).toBe(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE);
(0, _expect["default"])(error.details[0].message).toBe('Int must be of type Integer');
(0, _expect["default"])(error.details[1].name).toBe('string');
(0, _expect["default"])(error.details[1].type).toBe(_SimpleSchema.SimpleSchema.ErrorTypes.REQUIRED);
(0, _expect["default"])(error.details[1].message).toBe('String is required'); // In order for the message at the top of the stack trace to be useful,
// we set it to the first validation error message.
(0, _expect.default)(error.reason, 'Int must be of type Integer');
(0, _expect.default)(error.message, 'Int must be of type Integer [validation-error]');
(0, _expect["default"])(error.reason, 'Int must be of type Integer');
(0, _expect["default"])(error.message, 'Int must be of type Integer [validation-error]');
}

@@ -778,3 +787,3 @@

schema.validate({
int: '5'
"int": '5'
});

@@ -787,3 +796,3 @@ } catch (error) {

_SimpleSchema.SimpleSchema.validate({
int: '5'
"int": '5'
}, schema);

@@ -796,5 +805,5 @@ } catch (error) {

_SimpleSchema.SimpleSchema.validate({
int: '5'
"int": '5'
}, {
int: _SimpleSchema.SimpleSchema.Integer,
"int": _SimpleSchema.SimpleSchema.Integer,
string: String

@@ -808,3 +817,3 @@ });

schema.validator()({
int: '5'
"int": '5'
});

@@ -815,7 +824,7 @@ } catch (error) {

(0, _expect.default)(function () {
(0, _expect["default"])(function () {
schema.validator({
clean: true
})({
int: '5',
"int": '5',
string: 'test'

@@ -826,10 +835,10 @@ });

it('getFormValidator', function () {
const schema = new _SimpleSchema.SimpleSchema({
int: _SimpleSchema.SimpleSchema.Integer,
var schema = new _SimpleSchema.SimpleSchema({
"int": _SimpleSchema.SimpleSchema.Integer,
string: String
});
return Promise.all([schema.getFormValidator()({
int: '5'
}).then(errors => {
(0, _expect.default)(errors).toEqual([{
"int": '5'
}).then(function (errors) {
(0, _expect["default"])(errors).toEqual([{
dataType: 'Integer',

@@ -849,11 +858,11 @@ message: 'Int must be of type Integer',

})({
int: '5',
"int": '5',
string: 'test'
}).then(errors => {
(0, _expect.default)(errors).toEqual([]);
}).then(function (errors) {
(0, _expect["default"])(errors).toEqual([]);
})]);
});
it('validate takes an array', function () {
const schema = new _SimpleSchema.SimpleSchema({
int: _SimpleSchema.SimpleSchema.Integer,
var schema = new _SimpleSchema.SimpleSchema({
"int": _SimpleSchema.SimpleSchema.Integer,
string: String

@@ -863,14 +872,14 @@ });

function verify(error) {
(0, _expect.default)(error.name).toBe('ClientError');
(0, _expect.default)(error.errorType).toBe('ClientError');
(0, _expect.default)(error.error).toBe('validation-error');
(0, _expect.default)(error.details.length).toBe(2);
(0, _expect.default)(error.details[0].name).toBe('int');
(0, _expect.default)(error.details[0].type).toBe(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE);
(0, _expect.default)(error.details[1].name).toBe('string');
(0, _expect.default)(error.details[1].type).toBe(_SimpleSchema.SimpleSchema.ErrorTypes.REQUIRED); // In order for the message at the top of the stack trace to be useful,
(0, _expect["default"])(error.name).toBe('ClientError');
(0, _expect["default"])(error.errorType).toBe('ClientError');
(0, _expect["default"])(error.error).toBe('validation-error');
(0, _expect["default"])(error.details.length).toBe(2);
(0, _expect["default"])(error.details[0].name).toBe('int');
(0, _expect["default"])(error.details[0].type).toBe(_SimpleSchema.SimpleSchema.ErrorTypes.EXPECTED_TYPE);
(0, _expect["default"])(error.details[1].name).toBe('string');
(0, _expect["default"])(error.details[1].type).toBe(_SimpleSchema.SimpleSchema.ErrorTypes.REQUIRED); // In order for the message at the top of the stack trace to be useful,
// we set it to the first validation error message.
(0, _expect.default)(error.reason, 'Int must be of type Integer');
(0, _expect.default)(error.message, 'Int must be of type Integer [validation-error]');
(0, _expect["default"])(error.reason, 'Int must be of type Integer');
(0, _expect["default"])(error.message, 'Int must be of type Integer [validation-error]');
}

@@ -880,6 +889,6 @@

schema.validate([{
int: 5,
"int": 5,
string: 'test'
}, {
int: '5'
"int": '5'
}]);

@@ -892,6 +901,6 @@ } catch (error) {

_SimpleSchema.SimpleSchema.validate([{
int: 5,
"int": 5,
string: 'test'
}, {
int: '5'
"int": '5'
}], schema);

@@ -904,8 +913,8 @@ } catch (error) {

_SimpleSchema.SimpleSchema.validate([{
int: 5,
"int": 5,
string: 'test'
}, {
int: '5'
"int": '5'
}], {
int: _SimpleSchema.SimpleSchema.Integer,
"int": _SimpleSchema.SimpleSchema.Integer,
string: String

@@ -919,6 +928,6 @@ });

schema.validator()([{
int: 5,
"int": 5,
string: 'test'
}, {
int: '5'
"int": '5'
}]);

@@ -930,7 +939,7 @@ } catch (error) {

it('validationErrorTransform', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
string: String
});
_SimpleSchema.SimpleSchema.defineValidationErrorTransform(error => {
_SimpleSchema.SimpleSchema.defineValidationErrorTransform(function (error) {
error.message = 'validationErrorTransform';

@@ -943,3 +952,3 @@ return error;

} catch (e) {
(0, _expect.default)(e.message).toBe('validationErrorTransform');
(0, _expect["default"])(e.message).toBe('validationErrorTransform');
} // Don't mess up other tests

@@ -951,6 +960,6 @@

it('SimpleSchema.addDocValidator', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
string: String
});
const errorArray = [{
var errorArray = [{
name: 'firstName',

@@ -960,14 +969,14 @@ type: 'TOO_SILLY',

}];
const validatedObject = {
var validatedObject = {
string: 'String'
};
_SimpleSchema.SimpleSchema.addDocValidator(obj => {
(0, _expect.default)(obj).toEqual(validatedObject);
_SimpleSchema.SimpleSchema.addDocValidator(function (obj) {
(0, _expect["default"])(obj).toEqual(validatedObject);
return errorArray;
});
const context = schema.newContext();
var context = schema.newContext();
context.validate(validatedObject);
(0, _expect.default)(context.validationErrors()).toEqual(errorArray); // Don't mess up other tests
(0, _expect["default"])(context.validationErrors()).toEqual(errorArray); // Don't mess up other tests

@@ -977,6 +986,6 @@ _SimpleSchema.SimpleSchema._docValidators = [];

it('addDocValidator', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
string: String
});
const errorArray = [{
var errorArray = [{
name: 'firstName',

@@ -986,15 +995,15 @@ type: 'TOO_SILLY',

}];
const validatedObject = {
var validatedObject = {
string: 'String'
};
schema.addDocValidator(obj => {
(0, _expect.default)(obj).toEqual(validatedObject);
schema.addDocValidator(function (obj) {
(0, _expect["default"])(obj).toEqual(validatedObject);
return errorArray;
});
const context = schema.newContext();
var context = schema.newContext();
context.validate(validatedObject);
(0, _expect.default)(context.validationErrors()).toEqual(errorArray);
(0, _expect["default"])(context.validationErrors()).toEqual(errorArray);
});
it('sets _objectKeys', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
a: Object,

@@ -1007,3 +1016,3 @@ 'a.b': Object,

});
(0, _expect.default)(schema._objectKeys).toEqual({
(0, _expect["default"])(schema._objectKeys).toEqual({
'a.': ['b'],

@@ -1016,3 +1025,3 @@ 'a.b.': ['c'],

it('gets subschema objectKeys', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
a: {

@@ -1030,7 +1039,7 @@ type: new _SimpleSchema.SimpleSchema({

});
(0, _expect.default)(schema.objectKeys('a')).toEqual(['b']);
(0, _expect.default)(schema.objectKeys('a.b')).toEqual(['c']);
(0, _expect["default"])(schema.objectKeys('a')).toEqual(['b']);
(0, _expect["default"])(schema.objectKeys('a.b')).toEqual(['c']);
});
it('gets schema property by key', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
a: {

@@ -1059,8 +1068,8 @@ type: new _SimpleSchema.SimpleSchema({

});
(0, _expect.default)(schema.get('a', 'defaultValue')).toBe(undefined);
(0, _expect.default)(schema.get('a.b', 'defaultValue')).toBe('ab');
(0, _expect.default)(schema.get('a.d', 'maxCount')).toBe(3);
(0, _expect["default"])(schema.get('a', 'defaultValue')).toBe(undefined);
(0, _expect["default"])(schema.get('a.b', 'defaultValue')).toBe('ab');
(0, _expect["default"])(schema.get('a.d', 'maxCount')).toBe(3);
});
it('exposes defaultValue for a key', function () {
const schema = new _SimpleSchema.SimpleSchema({
var schema = new _SimpleSchema.SimpleSchema({
a: {

@@ -1080,13 +1089,13 @@ type: new _SimpleSchema.SimpleSchema({

});
(0, _expect.default)(schema.defaultValue('a')).toBe(undefined);
(0, _expect.default)(schema.defaultValue('a.b')).toBe('ab');
(0, _expect.default)(schema.defaultValue('a.b.c')).toBe('abc');
(0, _expect["default"])(schema.defaultValue('a')).toBe(undefined);
(0, _expect["default"])(schema.defaultValue('a.b')).toBe('ab');
(0, _expect["default"])(schema.defaultValue('a.b.c')).toBe('abc');
});
it('issue #232', function () {
let foo;
(0, _expect.default)(function () {
const schema3 = new _SimpleSchema.SimpleSchema({
var foo;
(0, _expect["default"])(function () {
var schema3 = new _SimpleSchema.SimpleSchema({
foo: String
});
const schema2 = new _SimpleSchema.SimpleSchema({
var schema2 = new _SimpleSchema.SimpleSchema({
field2: {

@@ -1105,4 +1114,4 @@ type: Array,

}).toNotThrow();
(0, _expect.default)(foo instanceof _SimpleSchema.SimpleSchema).toBe(true);
(0, _expect["default"])(foo instanceof _SimpleSchema.SimpleSchema).toBe(true);
});
});

@@ -6,15 +6,43 @@ "use strict";

});
exports.default = void 0;
exports["default"] = void 0;
var _mongoObject = _interopRequireDefault(require("mongo-object"));
var _extend = _interopRequireDefault(require("extend"));
var _extend2 = _interopRequireDefault(require("extend"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
class SimpleSchemaGroup {
constructor(...definitions) {
this.definitions = definitions.map(definition => {
if (_mongoObject.default.isBasicObject(definition)) return (0, _extend.default)(true, {}, definition);
function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
function _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var SimpleSchemaGroup =
/*#__PURE__*/
function () {
function SimpleSchemaGroup() {
_classCallCheck(this, SimpleSchemaGroup);
for (var _len = arguments.length, definitions = new Array(_len), _key = 0; _key < _len; _key++) {
definitions[_key] = arguments[_key];
}
this.definitions = definitions.map(function (definition) {
if (_mongoObject["default"].isBasicObject(definition)) return (0, _extend2["default"])(true, {}, definition);
if (definition instanceof RegExp) {

@@ -33,24 +61,30 @@ return {

get singleType() {
return this.definitions[0].type;
}
_createClass(SimpleSchemaGroup, [{
key: "clone",
value: function clone() {
return _construct(SimpleSchemaGroup, _toConsumableArray(this.definitions));
}
}, {
key: "extend",
value: function extend(otherGroup) {
// We extend based on index being the same. No better way I can think of at the moment.
this.definitions = this.definitions.map(function (def, index) {
var otherDef = otherGroup.definitions[index];
if (!otherDef) return def;
return (0, _extend2["default"])(true, {}, def, otherDef);
});
}
}, {
key: "singleType",
get: function get() {
return this.definitions[0].type;
}
}]);
clone() {
return new SimpleSchemaGroup(...this.definitions);
}
return SimpleSchemaGroup;
}();
extend(otherGroup) {
// We extend based on index being the same. No better way I can think of at the moment.
this.definitions = this.definitions.map((def, index) => {
const otherDef = otherGroup.definitions[index];
if (!otherDef) return def;
return (0, _extend.default)(true, {}, def, otherDef);
});
}
}
var _default = SimpleSchemaGroup;
exports.default = _default;
exports["default"] = _default;
module.exports = exports.default;
module.exports.default = exports.default;

@@ -6,42 +6,60 @@ "use strict";

});
exports.default = void 0;
exports["default"] = void 0;
class Address {
constructor(city, state) {
this.city = city;
this.state = state;
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
toString() {
return `${this.city}, ${this.state}`;
}
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
clone() {
return new Address(this.city, this.state);
}
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
equals(other) {
if (!(other instanceof Address)) {
return false;
}
var Address =
/*#__PURE__*/
function () {
function Address(city, state) {
_classCallCheck(this, Address);
return JSON.stringify(this) === JSON.stringify(other);
this.city = city;
this.state = state;
}
typeName() {
return 'Address';
}
_createClass(Address, [{
key: "toString",
value: function toString() {
return "".concat(this.city, ", ").concat(this.state);
}
}, {
key: "clone",
value: function clone() {
return new Address(this.city, this.state);
}
}, {
key: "equals",
value: function equals(other) {
if (!(other instanceof Address)) {
return false;
}
toJSONValue() {
return {
city: this.city,
state: this.state
};
}
return JSON.stringify(this) === JSON.stringify(other);
}
}, {
key: "typeName",
value: function typeName() {
return 'Address';
}
}, {
key: "toJSONValue",
value: function toJSONValue() {
return {
city: this.city,
state: this.state
};
}
}]);
}
return Address;
}();
var _default = Address;
exports.default = _default;
exports["default"] = _default;
module.exports = exports.default;
module.exports.default = exports.default;

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = expectErrorLength;
exports["default"] = expectErrorLength;

@@ -13,6 +13,6 @@ var _validate = _interopRequireDefault(require("./validate"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function expectErrorLength(...args) {
return (0, _expect.default)((0, _validate.default)(...args).validationErrors().length);
function expectErrorLength() {
return (0, _expect["default"])(_validate["default"].apply(void 0, arguments).validationErrors().length);
}

@@ -19,0 +19,0 @@

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = expectErrorOfTypeLength;
exports["default"] = expectErrorOfTypeLength;

@@ -13,11 +13,16 @@ var _validate = _interopRequireDefault(require("./validate"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function expectErrorOfTypeLength(type, ...args) {
const errors = (0, _validate.default)(...args).validationErrors();
let errorCount = 0;
errors.forEach(error => {
function expectErrorOfTypeLength(type) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
var errors = _validate["default"].apply(void 0, args).validationErrors();
var errorCount = 0;
errors.forEach(function (error) {
if (error.type === type) errorCount++;
});
return (0, _expect.default)(errorCount);
return (0, _expect["default"])(errorCount);
}

@@ -24,0 +29,0 @@

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = expectRequiredErrorLength;
exports["default"] = expectRequiredErrorLength;

@@ -15,11 +15,12 @@ var _validate = _interopRequireDefault(require("./validate"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function expectRequiredErrorLength(...args) {
const errors = (0, _validate.default)(...args).validationErrors();
let requiredErrorCount = 0;
errors.forEach(error => {
function expectRequiredErrorLength() {
var errors = _validate["default"].apply(void 0, arguments).validationErrors();
var requiredErrorCount = 0;
errors.forEach(function (error) {
if (error.type === _SimpleSchema.SimpleSchema.ErrorTypes.REQUIRED) requiredErrorCount++;
});
return (0, _expect.default)(requiredErrorCount);
return (0, _expect["default"])(requiredErrorCount);
}

@@ -26,0 +27,0 @@

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = expectValid;
exports["default"] = expectValid;

@@ -13,6 +13,6 @@ var _validate = _interopRequireDefault(require("./validate"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function expectValid(...args) {
(0, _expect.default)((0, _validate.default)(...args).isValid()).toBe(true);
function expectValid() {
(0, _expect["default"])(_validate["default"].apply(void 0, arguments).isValid()).toBe(true);
}

@@ -19,0 +19,0 @@

@@ -6,7 +6,7 @@ "use strict";

});
exports.default = void 0;
exports["default"] = void 0;
var _SimpleSchema = require("../SimpleSchema");
const friendsSchema = new _SimpleSchema.SimpleSchema({
var friendsSchema = new _SimpleSchema.SimpleSchema({
name: {

@@ -63,4 +63,4 @@ type: String,

var _default = friendsSchema;
exports.default = _default;
exports["default"] = _default;
module.exports = exports.default;
module.exports.default = exports.default;

@@ -6,16 +6,18 @@ "use strict";

});
exports.default = void 0;
exports["default"] = void 0;
var _SimpleSchema = require("../SimpleSchema");
const optionalCustomSchema = new _SimpleSchema.SimpleSchema({
var optionalCustomSchema = new _SimpleSchema.SimpleSchema({
foo: {
type: String,
optional: true,
custom: () => 'custom'
custom: function custom() {
return 'custom';
}
}
});
var _default = optionalCustomSchema;
exports.default = _default;
exports["default"] = _default;
module.exports = exports.default;
module.exports.default = exports.default;

@@ -6,39 +6,31 @@ "use strict";

});
exports.default = void 0;
exports["default"] = void 0;
var _SimpleSchema = require("../SimpleSchema");
const requiredCustomSchema = new _SimpleSchema.SimpleSchema({
var requiredCustomSchema = new _SimpleSchema.SimpleSchema({
a: {
type: Array,
custom() {// Just adding custom to trigger extra validation
custom: function custom() {// Just adding custom to trigger extra validation
}
},
'a.$': {
type: Object,
custom() {// Just adding custom to trigger extra validation
custom: function custom() {// Just adding custom to trigger extra validation
}
},
b: {
type: Array,
custom() {// Just adding custom to trigger extra validation
custom: function custom() {// Just adding custom to trigger extra validation
}
},
'b.$': {
type: Object,
custom() {// Just adding custom to trigger extra validation
custom: function custom() {// Just adding custom to trigger extra validation
}
}
});
var _default = requiredCustomSchema;
exports.default = _default;
exports["default"] = _default;
module.exports = exports.default;
module.exports.default = exports.default;

@@ -6,7 +6,7 @@ "use strict";

});
exports.default = void 0;
exports["default"] = void 0;
var _SimpleSchema = require("../SimpleSchema");
const requiredSchema = new _SimpleSchema.SimpleSchema({
var requiredSchema = new _SimpleSchema.SimpleSchema({
requiredString: {

@@ -56,4 +56,4 @@ type: String

var _default = requiredSchema;
exports.default = _default;
exports["default"] = _default;
module.exports = exports.default;
module.exports.default = exports.default;

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = void 0;
exports["default"] = void 0;

@@ -15,5 +15,5 @@ var _SimpleSchema = require("../SimpleSchema");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
const testSchema = new _SimpleSchema.SimpleSchema({
var testSchema = new _SimpleSchema.SimpleSchema({
string: {

@@ -62,3 +62,3 @@ type: String,

},
boolean: {
"boolean": {
type: Boolean,

@@ -105,11 +105,8 @@ optional: true

optional: true,
min() {
min: function min() {
return 10;
},
max() {
max: function max() {
return 20;
}
},

@@ -177,11 +174,8 @@ minMaxNumberExclusive: {

optional: true,
min() {
min: function min() {
return new Date(Date.UTC(2013, 0, 1));
},
max() {
max: function max() {
return new Date(Date.UTC(2013, 11, 31));
}
},

@@ -199,3 +193,3 @@ email: {

customObject: {
type: _Address.default,
type: _Address["default"],
optional: true,

@@ -216,4 +210,4 @@ blackbox: true

var _default = testSchema;
exports.default = _default;
exports["default"] = _default;
module.exports = exports.default;
module.exports.default = exports.default;

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

});
exports.default = validate;
exports["default"] = validate;
function validate(ss, doc, options) {
const context = ss.newContext();
var context = ss.newContext();
context.validate(doc, options);

@@ -12,0 +12,0 @@ return context;

@@ -6,7 +6,7 @@ "use strict";

});
exports.default = appendAffectedKey;
exports["default"] = appendAffectedKey;
function appendAffectedKey(affectedKey, key) {
if (key === '$each') return affectedKey;
return affectedKey ? `${affectedKey}.${key}` : key;
return affectedKey ? "".concat(affectedKey, ".").concat(key) : key;
}

@@ -13,0 +13,0 @@

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = dateToDateString;
exports["default"] = dateToDateString;

@@ -13,7 +13,7 @@ /**

function dateToDateString(date) {
let m = date.getUTCMonth() + 1;
if (m < 10) m = `0${m}`;
let d = date.getUTCDate();
if (d < 10) d = `0${d}`;
return `${date.getUTCFullYear()}-${m}-${d}`;
var m = date.getUTCMonth() + 1;
if (m < 10) m = "0".concat(m);
var d = date.getUTCDate();
if (d < 10) d = "0".concat(d);
return "".concat(date.getUTCFullYear(), "-").concat(m, "-").concat(d);
}

@@ -20,0 +20,0 @@

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = forEachKeyAncestor;
exports["default"] = forEachKeyAncestor;

@@ -14,5 +14,5 @@ /**

function forEachKeyAncestor(key, loopFunc) {
let lastDot; // Iterate the dot-syntax hierarchy
var lastDot; // Iterate the dot-syntax hierarchy
let ancestor = key;
var ancestor = key;

@@ -24,3 +24,3 @@ do {

ancestor = ancestor.slice(0, lastDot);
const remainder = key.slice(ancestor.length + 1);
var remainder = key.slice(ancestor.length + 1);
loopFunc(ancestor, remainder); // Remove last path component

@@ -27,0 +27,0 @@ }

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = getKeysWithValueInObj;
exports["default"] = getKeysWithValueInObj;

@@ -15,9 +15,11 @@ /**

function getKeysWithValueInObj(obj, matchKey) {
const keysWithValue = [];
var keysWithValue = [];
const keyAdjust = k => k.slice(0, matchKey.length + 1);
var keyAdjust = function keyAdjust(k) {
return k.slice(0, matchKey.length + 1);
};
const matchKeyPlusDot = `${matchKey}.`;
Object.keys(obj || {}).forEach(key => {
const val = obj[key];
var matchKeyPlusDot = "".concat(matchKey, ".");
Object.keys(obj || {}).forEach(function (key) {
var val = obj[key];
if (val === undefined || val === null) return;

@@ -24,0 +26,0 @@

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = getLastPartOfKey;
exports["default"] = getLastPartOfKey;

@@ -17,4 +17,4 @@ /**

function getLastPartOfKey(key, ancestorKey) {
let lastPart = '';
const startString = `${ancestorKey}.`;
var lastPart = '';
var startString = "".concat(ancestorKey, ".");

@@ -21,0 +21,0 @@ if (key.indexOf(startString) === 0) {

@@ -7,3 +7,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -13,7 +13,7 @@ /* eslint-disable func-names, prefer-arrow-callback */

it('returns the correct string for a non-array key', function () {
(0, _expect.default)((0, _getLastPartOfKey.default)('a.b.c', 'a')).toBe('b.c');
(0, _expect["default"])((0, _getLastPartOfKey["default"])('a.b.c', 'a')).toBe('b.c');
});
it('returns the correct string for an array key', function () {
(0, _expect.default)((0, _getLastPartOfKey.default)('a.b.$.c', 'a.b')).toBe('c');
(0, _expect["default"])((0, _getLastPartOfKey["default"])('a.b.$.c', 'a.b')).toBe('c');
});
});

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = getParentOfKey;
exports["default"] = getParentOfKey;

@@ -15,3 +15,3 @@ /**

function getParentOfKey(key, withEndDot) {
const lastDot = key.lastIndexOf('.');
var lastDot = key.lastIndexOf('.');
return lastDot === -1 ? '' : key.slice(0, lastDot + Number(!!withEndDot));

@@ -18,0 +18,0 @@ }

@@ -8,4 +8,4 @@ "use strict";

enumerable: true,
get: function () {
return _appendAffectedKey.default;
get: function get() {
return _appendAffectedKey["default"];
}

@@ -15,4 +15,4 @@ });

enumerable: true,
get: function () {
return _dateToDateString.default;
get: function get() {
return _dateToDateString["default"];
}

@@ -22,4 +22,4 @@ });

enumerable: true,
get: function () {
return _forEachKeyAncestor.default;
get: function get() {
return _forEachKeyAncestor["default"];
}

@@ -29,4 +29,4 @@ });

enumerable: true,
get: function () {
return _getKeysWithValueInObj.default;
get: function get() {
return _getKeysWithValueInObj["default"];
}

@@ -36,4 +36,4 @@ });

enumerable: true,
get: function () {
return _getLastPartOfKey.default;
get: function get() {
return _getLastPartOfKey["default"];
}

@@ -43,4 +43,4 @@ });

enumerable: true,
get: function () {
return _getParentOfKey.default;
get: function get() {
return _getParentOfKey["default"];
}

@@ -50,4 +50,4 @@ });

enumerable: true,
get: function () {
return _isObjectWeShouldTraverse.default;
get: function get() {
return _isObjectWeShouldTraverse["default"];
}

@@ -57,4 +57,4 @@ });

enumerable: true,
get: function () {
return _looksLikeModifier.default;
get: function get() {
return _looksLikeModifier["default"];
}

@@ -79,2 +79,2 @@ });

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = isObjectWeShouldTraverse;
exports["default"] = isObjectWeShouldTraverse;

@@ -9,0 +9,0 @@ function isObjectWeShouldTraverse(val) {

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = looksLikeModifier;
exports["default"] = looksLikeModifier;

@@ -13,3 +13,5 @@ /**

function looksLikeModifier(obj) {
return !!Object.keys(obj || {}).find(key => key.substring(0, 1) === '$');
return !!Object.keys(obj || {}).find(function (key) {
return key.substring(0, 1) === '$';
});
}

@@ -16,0 +18,0 @@

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = allowedValuesValidator;
exports["default"] = allowedValuesValidator;

@@ -13,9 +13,9 @@ var _SimpleSchema = require("../SimpleSchema");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function allowedValuesValidator() {
if (!this.valueShouldBeChecked) return;
const allowedValues = this.definition.allowedValues;
var allowedValues = this.definition.allowedValues;
if (!allowedValues) return;
let isAllowed; // set defined in scope and allowedValues is its instance
var isAllowed; // set defined in scope and allowedValues is its instance

@@ -25,3 +25,3 @@ if (typeof Set === 'function' && allowedValues instanceof Set) {

} else {
isAllowed = (0, _lodash.default)(allowedValues, this.value);
isAllowed = (0, _lodash["default"])(allowedValues, this.value);
}

@@ -28,0 +28,0 @@

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = requiredValidator;
exports["default"] = requiredValidator;

@@ -22,14 +22,10 @@ var _SimpleSchema = require("../SimpleSchema");

function requiredValidator() {
const {
definition,
isInArrayItemObject,
isInSubObject,
key,
obj,
operator,
value
} = this;
const {
optional
} = definition;
var definition = this.definition,
isInArrayItemObject = this.isInArrayItemObject,
isInSubObject = this.isInSubObject,
key = this.key,
obj = this.obj,
operator = this.operator,
value = this.value;
var optional = definition.optional;
if (optional) return; // If value is null, no matter what, we add required

@@ -47,9 +43,9 @@

const keysWithValueInSet = (0, _utility.getKeysWithValueInObj)(obj.$set, key);
var keysWithValueInSet = (0, _utility.getKeysWithValueInObj)(obj.$set, key);
if (keysWithValueInSet.length) return;
const keysWithValueInSetOnInsert = (0, _utility.getKeysWithValueInObj)(obj.$setOnInsert, key);
var keysWithValueInSetOnInsert = (0, _utility.getKeysWithValueInObj)(obj.$setOnInsert, key);
if (keysWithValueInSetOnInsert.length) return; // In the case of $set and $setOnInsert, the value may be undefined here
// but it is set in another operator. So check that first.
const fieldInfo = this.field(key);
var fieldInfo = this.field(key);
if (fieldInfo.isSet && fieldInfo.value !== null) return; // Required if in an array or sub object

@@ -56,0 +52,0 @@

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = doArrayChecks;
exports["default"] = doArrayChecks;

@@ -9,0 +9,0 @@ var _SimpleSchema = require("../../SimpleSchema");

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = doDateChecks;
exports["default"] = doDateChecks;

@@ -9,0 +9,0 @@ var _SimpleSchema = require("../../SimpleSchema");

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = doNumberChecks;
exports["default"] = doNumberChecks;

@@ -9,0 +9,0 @@ var _SimpleSchema = require("../../SimpleSchema");

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = doStringChecks;
exports["default"] = doStringChecks;

@@ -46,4 +46,4 @@ var _SimpleSchema = require("../../SimpleSchema");

if (Array.isArray(def.regEx)) {
let regExError;
def.regEx.every(re => {
var regExError;
def.regEx.every(function (re) {
if (!re.test(keyValue)) {

@@ -50,0 +50,0 @@ regExError = {

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = typeValidator;
exports["default"] = typeValidator;

@@ -19,13 +19,13 @@ var _SimpleSchema = require("../../SimpleSchema");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function typeValidator() {
if (!this.valueShouldBeChecked) return;
const def = this.definition;
const expectedType = def.type;
const keyValue = this.value;
const op = this.operator;
if (expectedType === String) return (0, _doStringChecks.default)(def, keyValue);
if (expectedType === Number) return (0, _doNumberChecks.default)(def, keyValue, op, false);
if (expectedType === _SimpleSchema.SimpleSchema.Integer) return (0, _doNumberChecks.default)(def, keyValue, op, true);
var def = this.definition;
var expectedType = def.type;
var keyValue = this.value;
var op = this.operator;
if (expectedType === String) return (0, _doStringChecks["default"])(def, keyValue);
if (expectedType === Number) return (0, _doNumberChecks["default"])(def, keyValue, op, false);
if (expectedType === _SimpleSchema.SimpleSchema.Integer) return (0, _doNumberChecks["default"])(def, keyValue, op, true);

@@ -50,3 +50,3 @@ if (expectedType === Boolean) {

if (expectedType === Array) return (0, _doArrayChecks.default)(def, keyValue);
if (expectedType === Array) return (0, _doArrayChecks["default"])(def, keyValue);

@@ -60,3 +60,3 @@ if (expectedType instanceof Function) {

if (expectedType === Date) return (0, _doDateChecks.default)(def, keyValue);
if (expectedType === Date) return (0, _doDateChecks["default"])(def, keyValue);
}

@@ -63,0 +63,0 @@ }

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = void 0;
exports["default"] = void 0;

@@ -15,6 +15,18 @@ var _mongoObject = _interopRequireDefault(require("mongo-object"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
class ValidationContext {
constructor(ss) {
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var ValidationContext =
/*#__PURE__*/
function () {
function ValidationContext(ss) {
var _this = this;
_classCallCheck(this, ValidationContext);
this._simpleSchema = ss;

@@ -26,5 +38,3 @@ this._schema = ss.schema();

this._deps = {};
const {
tracker
} = ss._constructorOptions;
var tracker = ss._constructorOptions.tracker;

@@ -34,4 +44,4 @@ if (tracker) {

this._schemaKeys.forEach(key => {
this._deps[key] = new tracker.Dependency();
this._schemaKeys.forEach(function (key) {
_this._deps[key] = new tracker.Dependency();
});

@@ -41,120 +51,186 @@ }

_markKeyChanged(key) {
const genericKey = _mongoObject.default.makeKeyGeneric(key);
_createClass(ValidationContext, [{
key: "_markKeyChanged",
value: function _markKeyChanged(key) {
var genericKey = _mongoObject["default"].makeKeyGeneric(key);
if (this._deps.hasOwnProperty(genericKey)) this._deps[genericKey].changed();
}
if (this._deps.hasOwnProperty(genericKey)) this._deps[genericKey].changed();
}
}, {
key: "_markKeysChanged",
value: function _markKeysChanged(keys) {
var _this2 = this;
_markKeysChanged(keys) {
if (!keys || !Array.isArray(keys) || !keys.length) return;
keys.forEach(key => this._markKeyChanged(key));
this._depsAny && this._depsAny.changed();
}
if (!keys || !Array.isArray(keys) || !keys.length) return;
keys.forEach(function (key) {
return _this2._markKeyChanged(key);
});
this._depsAny && this._depsAny.changed();
}
}, {
key: "setValidationErrors",
value: function setValidationErrors(errors) {
var previousValidationErrors = this._validationErrors.map(function (o) {
return o.name;
});
setValidationErrors(errors) {
const previousValidationErrors = this._validationErrors.map(o => o.name);
var newValidationErrors = errors.map(function (o) {
return o.name;
});
this._validationErrors = errors; // Mark all previous plus all new as changed
const newValidationErrors = errors.map(o => o.name);
this._validationErrors = errors; // Mark all previous plus all new as changed
var changedKeys = previousValidationErrors.concat(newValidationErrors);
const changedKeys = previousValidationErrors.concat(newValidationErrors);
this._markKeysChanged(changedKeys);
}
}, {
key: "addValidationErrors",
value: function addValidationErrors(errors) {
var _this3 = this;
this._markKeysChanged(changedKeys);
}
var newValidationErrors = errors.map(function (o) {
return o.name;
});
errors.forEach(function (error) {
return _this3._validationErrors.push(error);
}); // Mark all new as changed
addValidationErrors(errors) {
const newValidationErrors = errors.map(o => o.name);
errors.forEach(error => this._validationErrors.push(error)); // Mark all new as changed
this._markKeysChanged(newValidationErrors);
} // Reset the validationErrors array
this._markKeysChanged(newValidationErrors);
} // Reset the validationErrors array
}, {
key: "reset",
value: function reset() {
this.setValidationErrors([]);
}
}, {
key: "getErrorForKey",
value: function getErrorForKey(key) {
var genericKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _mongoObject["default"].makeKeyGeneric(key);
var errors = this._validationErrors;
return (0, _lodash["default"])(errors, {
name: key
}) || (0, _lodash["default"])(errors, {
name: genericKey
});
}
}, {
key: "_keyIsInvalid",
value: function _keyIsInvalid(key, genericKey) {
return !!this.getErrorForKey(key, genericKey);
} // Like the internal one, but with deps
}, {
key: "keyIsInvalid",
value: function keyIsInvalid(key) {
var genericKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _mongoObject["default"].makeKeyGeneric(key);
if (this._deps.hasOwnProperty(genericKey)) this._deps[genericKey].depend();
return this._keyIsInvalid(key, genericKey);
}
}, {
key: "keyErrorMessage",
value: function keyErrorMessage(key) {
var genericKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _mongoObject["default"].makeKeyGeneric(key);
if (this._deps.hasOwnProperty(genericKey)) this._deps[genericKey].depend();
var errorObj = this.getErrorForKey(key, genericKey);
if (!errorObj) return '';
return this._simpleSchema.messageForError(errorObj);
}
/**
* Validates the object against the simple schema and sets a reactive array of error objects
*/
reset() {
this.setValidationErrors([]);
}
}, {
key: "validate",
value: function validate(obj) {
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref$extendedCustomCo = _ref.extendedCustomContext,
extendedCustomContext = _ref$extendedCustomCo === void 0 ? {} : _ref$extendedCustomCo,
_ref$ignore = _ref.ignore,
ignoreTypes = _ref$ignore === void 0 ? [] : _ref$ignore,
keysToValidate = _ref.keys,
_ref$modifier = _ref.modifier,
isModifier = _ref$modifier === void 0 ? false : _ref$modifier,
mongoObject = _ref.mongoObject,
_ref$upsert = _ref.upsert,
isUpsert = _ref$upsert === void 0 ? false : _ref$upsert;
getErrorForKey(key, genericKey = _mongoObject.default.makeKeyGeneric(key)) {
const errors = this._validationErrors;
return (0, _lodash.default)(errors, {
name: key
}) || (0, _lodash.default)(errors, {
name: genericKey
});
}
var validationErrors = (0, _doValidation["default"])({
extendedCustomContext: extendedCustomContext,
ignoreTypes: ignoreTypes,
isModifier: isModifier,
isUpsert: isUpsert,
keysToValidate: keysToValidate,
mongoObject: mongoObject,
obj: obj,
schema: this._simpleSchema,
validationContext: this
});
_keyIsInvalid(key, genericKey) {
return !!this.getErrorForKey(key, genericKey);
} // Like the internal one, but with deps
if (keysToValidate) {
// We have only revalidated the listed keys, so if there
// are any other existing errors that are NOT in the keys list,
// we should keep these errors.
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
var _loop = function _loop() {
var error = _step.value;
var wasValidated = keysToValidate.some(function (key) {
return key === error.name || error.name.startsWith("".concat(key, "."));
});
if (!wasValidated) validationErrors.push(error);
};
keyIsInvalid(key, genericKey = _mongoObject.default.makeKeyGeneric(key)) {
if (this._deps.hasOwnProperty(genericKey)) this._deps[genericKey].depend();
return this._keyIsInvalid(key, genericKey);
}
for (var _iterator = this._validationErrors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
_loop();
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator["return"] != null) {
_iterator["return"]();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
keyErrorMessage(key, genericKey = _mongoObject.default.makeKeyGeneric(key)) {
if (this._deps.hasOwnProperty(genericKey)) this._deps[genericKey].depend();
const errorObj = this.getErrorForKey(key, genericKey);
if (!errorObj) return '';
return this._simpleSchema.messageForError(errorObj);
}
/**
* Validates the object against the simple schema and sets a reactive array of error objects
*/
this.setValidationErrors(validationErrors); // Return true if it was valid; otherwise, return false
return !validationErrors.length;
}
}, {
key: "isValid",
value: function isValid() {
this._depsAny && this._depsAny.depend();
return this._validationErrors.length === 0;
}
}, {
key: "validationErrors",
value: function validationErrors() {
this._depsAny && this._depsAny.depend();
return this._validationErrors;
}
}, {
key: "clean",
value: function clean() {
var _this$_simpleSchema;
validate(obj, {
extendedCustomContext = {},
ignore: ignoreTypes = [],
keys: keysToValidate,
modifier: isModifier = false,
mongoObject,
upsert: isUpsert = false
} = {}) {
const validationErrors = (0, _doValidation.default)({
extendedCustomContext,
ignoreTypes,
isModifier,
isUpsert,
keysToValidate,
mongoObject,
obj,
schema: this._simpleSchema,
validationContext: this
});
if (keysToValidate) {
// We have only revalidated the listed keys, so if there
// are any other existing errors that are NOT in the keys list,
// we should keep these errors.
for (const error of this._validationErrors) {
const wasValidated = keysToValidate.some(key => key === error.name || error.name.startsWith(`${key}.`));
if (!wasValidated) validationErrors.push(error);
}
return (_this$_simpleSchema = this._simpleSchema).clean.apply(_this$_simpleSchema, arguments);
}
}]);
this.setValidationErrors(validationErrors); // Return true if it was valid; otherwise, return false
return ValidationContext;
}();
return !validationErrors.length;
}
isValid() {
this._depsAny && this._depsAny.depend();
return this._validationErrors.length === 0;
}
validationErrors() {
this._depsAny && this._depsAny.depend();
return this._validationErrors;
}
clean(...args) {
return this._simpleSchema.clean(...args);
}
}
exports.default = ValidationContext;
exports["default"] = ValidationContext;
module.exports = exports.default;
module.exports.default = exports.default;
{
"name": "simpl-schema",
"version": "1.5.6",
"version": "1.5.7",
"description": "A schema validation package that supports direct validation of MongoDB update modifier objects.",

@@ -31,3 +31,3 @@ "author": "Eric Dobbertin <aldeed@gmail.com>",

"dependencies": {
"clone": "^2.1.1",
"clone": "^2.1.2",
"extend": "^3.0.2",

@@ -44,17 +44,17 @@ "lodash.every": "^4.6.0",

"lodash.uniq": "^4.5.0",
"message-box": "^0.2.0",
"message-box": "^0.2.2",
"mongo-object": "^0.1.3"
},
"devDependencies": {
"@babel/cli": "7.0.0",
"@babel/core": "7.0.0",
"@babel/plugin-proposal-class-properties": "7.3.0",
"@babel/plugin-proposal-object-rest-spread": "7.0.0",
"@babel/polyfill": "7.2.5",
"@babel/preset-env": "7.0.0",
"@babel/register": "7.0.0",
"@babel/cli": "7.8.4",
"@babel/core": "7.8.4",
"@babel/plugin-proposal-class-properties": "7.8.3",
"@babel/plugin-proposal-object-rest-spread": "7.8.3",
"@babel/polyfill": "7.8.3",
"@babel/preset-env": "7.8.4",
"@babel/register": "7.8.3",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "8.2.3",
"babel-eslint": "10.0.3",
"babel-plugin-add-module-exports": "^1.0.2",
"eslint": "^2.13.0",
"eslint": "^6.8.0",
"eslint-config-airbnb": "^9.0.1",

@@ -65,14 +65,7 @@ "eslint-plugin-import": "^1.7.0",

"expect": "^1.20.1",
"mocha": "^5.2.0"
"mocha": "^7.0.1"
},
"babel": {
"presets": [
[
"@babel/env",
{
"targets": {
"node": "8"
}
}
]
"@babel/env"
],

@@ -107,2 +100,3 @@ "plugins": [

"no-underscore-dangle": 0,
"no-useless-escape": 0,
"no-use-before-define": [

@@ -109,0 +103,0 @@ 2,

Sorry, the diff of this file is not supported yet

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