Comparing version 0.8.0 to 0.8.1
@@ -34,2 +34,8 @@ ## [Unreleased] | ||
## [0.8.1] - 2018-01-12 | ||
### Fixed | ||
* Bugs in normalization and validation type methods (Document payload) | ||
## [0.8.0] - 2018-01-12 | ||
@@ -372,2 +378,3 @@ | ||
[0.8.1]: https://github.com/Yonirt/moltyjs/compare/v0.8.0...v0.8.1 | ||
[0.8.0]: https://github.com/Yonirt/moltyjs/compare/v0.7.0...v0.8.0 | ||
@@ -374,0 +381,0 @@ [0.7.0]: https://github.com/Yonirt/moltyjs/compare/v0.6.2...v0.7.0 |
@@ -110,2 +110,4 @@ 'use strict'; | ||
return _asyncToGenerator(function* () { | ||
if (!payload || Object.keys(payload).length === 0 && payload.constructor === Object) throw new Error('Document payload is required'); | ||
// Check if paylaod field names are correct | ||
@@ -238,3 +240,3 @@ _this._validatePayloadFieldNames(payload, _this._schemaNormalized); | ||
// Array | ||
if (!schema[key].type && isArray(schema[key])) { | ||
if (isArray(schema[key]) && payload[key]) { | ||
var _iteratorNormalCompletion2 = true; | ||
@@ -272,3 +274,3 @@ var _didIteratorError2 = false; | ||
// Objects nested | ||
if (!schema[key].type && isObject(schema[key]) && !isArray(schema[key])) { | ||
if (isObject(schema[key]) && !isArray(schema[key]) && payload[key]) { | ||
try { | ||
@@ -369,5 +371,13 @@ yield _this2._validatePayloadFieldValues(payload[key], schema[key], parentPayload); | ||
Object.keys(schema).forEach(key => { | ||
// Array | ||
if (!schema[key].type && isArray(schema[key]) && payload[key] && payload[key].length > 0) { | ||
for (let i = 0; i < payload[key].length; i++) { | ||
payload[key][i] = this._normalizePayload(payload[key][i], schema[key][0]); | ||
} | ||
} | ||
// Objects nested | ||
if (!schema[key].type && isObject(schema[key])) { | ||
payload[key] = this._normalizePayload(payload[key], schema[key]); | ||
if (!schema[key].type && isObject(schema[key]) && !isArray(schema[key])) { | ||
const aux = this._normalizePayload(payload[key], schema[key]); | ||
if (aux) payload[key] = aux; | ||
return; | ||
@@ -374,0 +384,0 @@ } |
{ | ||
"name": "moltyjs", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"description": "A tiny ODM for MongoDB with multy tenancy support.", | ||
@@ -12,3 +12,4 @@ "main": "lib/index.js", | ||
"test": "mocha \"./{,!(node_modules)/**/}*.test.js\" --require babel-core/register --require babel-polyfill --recursive --reporter spec --timeout 5000 --exit", | ||
"prepublish": "npm run build", | ||
"prepublishOnly": "npm run build", | ||
"prepare": "npm run build", | ||
"release": "np" | ||
@@ -15,0 +16,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
117107
2141