mongorito-tcomb
Advanced tools
Comparing version 0.9.1 to 0.9.5
// 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" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28063
339
7
+ Addedco@^4.6.0
+ Addedbluebird@3.7.2(transitive)
+ Addedis-generator-fn@1.0.0(transitive)
+ Addedlodash.result@4.5.2(transitive)
+ Addedmongorito@2.2.0(transitive)
- Removedarray-generators@1.1.0(transitive)
- Removedkoa-compose@2.5.1(transitive)
- Removedlodash._baseget@3.7.2(transitive)
- Removedlodash._baseslice@3.0.3(transitive)
- Removedlodash._topath@3.8.1(transitive)
- Removedlodash.isarray@3.0.4(transitive)
- Removedlodash.isfunction@3.0.9(transitive)
- Removedlodash.result@3.1.2(transitive)
- Removedmongorito@1.4.6(transitive)
Updatedmongorito@^2.0.0