Permalink
Browse files

Add a compatibility layer to the ‘Error’ object

  • Loading branch information...
1 parent 3fcd979 commit 14db900ae0d48c8b80f9089bcc6192f229a2ec91 @Baggz committed Mar 15, 2012
Showing with 22 additions and 3 deletions.
  1. +22 −3 src/engines/json/validationError.js
@@ -7,9 +7,25 @@ var ValidationError = function() {
this.length = 0;
};
-ValidationError.prototype.push = function(item) {
- this[this.length] = item;
+ValidationError.prototype.push = function(error) {
+
+ this[this.length] = {
+
+ property: error.property,
+ propertyValue: error.propertyValue,
+ attributeName: error.attributeName,
+ attributeValue: error.attributeValue,
+ message: error.message,
+
+ // Deprecated
+ validator: error.attributeName,
+ validatorName: error.attributeName,
+ validatoValue: error.attributeValue
+
+ };
+
this.length += 1;
+
};
/**
@@ -19,6 +35,9 @@ ValidationError.prototype.getProperties = function() {
return pluck(this, 'property');
};
+/**
+ * GetMessages
+ */
ValidationError.prototype.getMessages = function() {
-
+ return pluck(this, 'message');
};

0 comments on commit 14db900

Please sign in to comment.