diamond.js
Advanced tools
Comparing version 0.2.5 to 0.2.6
@@ -37,3 +37,4 @@ // Generated by CoffeeScript 1.7.1 | ||
this.properties = new Object; | ||
this.name = this.constructor.name; | ||
this.collection = this.constructor.collection || this.constructor.name.toLowerCase(); | ||
this.hasError = false; | ||
_ref = this.constructor.properties; | ||
@@ -67,7 +68,8 @@ for (k in _ref) { | ||
Model.prototype.validate = function(options) { | ||
var error, errors, k, v, _ref; | ||
var error, k, v, _ref; | ||
if (options == null) { | ||
options = {}; | ||
} | ||
errors = {}; | ||
this.hasError = false; | ||
this.errors = new Object; | ||
_ref = this.constructor.validations; | ||
@@ -78,6 +80,10 @@ for (k in _ref) { | ||
if (error) { | ||
errors[k] = error; | ||
this.hasError = true; | ||
} | ||
if (error) { | ||
this.errors[k] = error; | ||
} | ||
} | ||
return errors; | ||
this.errors = this.hasError ? this.errors : null; | ||
return this.errors; | ||
}; | ||
@@ -84,0 +90,0 @@ |
@@ -27,7 +27,15 @@ // Generated by CoffeeScript 1.7.1 | ||
Storage.prototype.save = function(callback) { | ||
return Diamond.getInstance().db.save(this, callback); | ||
if (!this.hasError) { | ||
return Diamond.getInstance().db.save(this, callback); | ||
} else { | ||
return callback(this.errors); | ||
} | ||
}; | ||
Storage.prototype.update = function(options, callback) { | ||
return Diamond.getInstance().db.update(this, options, this.oroperties, callback); | ||
if (!this.hasError) { | ||
return Diamond.getInstance().db.update(this, options, this.properties, callback); | ||
} else { | ||
return callback(this.errors); | ||
} | ||
}; | ||
@@ -34,0 +42,0 @@ |
{ | ||
"name": "diamond.js", | ||
"description": "MVC web framework", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Arthur Xavier", |
Sorry, the diff of this file is not supported yet
27866
507