Skip to content

Commit

Permalink
Add a compatibility layer to the ‘Error’ object
Browse files Browse the repository at this point in the history
  • Loading branch information
František Hába committed Mar 15, 2012
1 parent 3fcd979 commit 14db900
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/engines/json/validationError.js
Expand Up @@ -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;

};

/**
Expand All @@ -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.