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

mongorito-tcomb

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongorito-tcomb - npm Package Compare versions

Comparing version 0.9.1 to 0.9.5

34

lib/index.js
// Generated by CoffeeScript 1.10.0
(function() {
var ID, Mongorito, extractLists, getPathForType, patch, regexID, t, unique,
var ID, Mongorito, co, extractLists, getPathForType, patch, regexID, t, unique,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },

@@ -16,2 +16,4 @@ hasProp = {}.hasOwnProperty,

co = require('co');
patch = function(Model) {

@@ -40,2 +42,5 @@ var Son;

Son.__super__.configure.call(this);
if (!this.Schema) {
return;
}
this.before('save', 'validate');

@@ -45,3 +50,3 @@ return this.before('save', 'ensureUnique');

Son.prototype.validateIDs = function*() {
Son.prototype.validateIDs = co.wrap(function*() {
var id, ids, j, len, path, ref1, results, type;

@@ -60,6 +65,6 @@ ids = extractLists(this.attributes, this.ids);

return results;
};
});
Son.prototype.ensureUnique = function*(next) {
var hook, i, j, k, len, len1, path, ref1, ref2, type, uniques;
Son.prototype.ensureUnique = co.wrap(function*() {
var hook, i, j, k, len, len1, path, ref1, ref2, results, type, uniques;
uniques = getPathForType(this.Schema, 'unique');

@@ -73,2 +78,3 @@ for (j = 0, len = uniques.length; j < len; j++) {

ref2 = this._hooks.before.save;
results = [];
for (i = k = 0, len1 = ref2.length; k < len1; i = ++k) {

@@ -79,19 +85,17 @@ hook = ref2[i];

break;
} else {
results.push(void 0);
}
}
return (yield next);
};
return results;
});
Son.prototype.validate = function*(next) {
Son.prototype.validate = co.wrap(function*() {
var val;
if (!this.haveSchema) {
return;
}
val = t.validate(this.attributes, this.Schema);
val = t.validate(this.get(), this.Schema);
if (!val.isValid()) {
throw val.errors;
}
(yield this.validateIDs());
return (yield next);
};
return (yield this.validateIDs());
});

@@ -98,0 +102,0 @@ return Son;

{
"name": "mongorito-tcomb",
"version": "0.9.1",
"version": "0.9.5",
"description": "Bring schema validation to Mongorito thanks to tcomb",

@@ -31,6 +31,7 @@ "main": "./lib/index.js",

"dependencies": {
"co": "^4.6.0",
"colors": "^1.1.2",
"get-value": "^2.0.3",
"kerberos": "0.0.18",
"mongorito": "^1.4.6",
"mongorito": "^2.0.0",
"tcomb": "^2.7.0",

@@ -37,0 +38,0 @@ "tcomb-validation": "^2.3.0"

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc