Permalink
Browse files

The ‘addError’ method has the ability to overwrite the ‘Error’ object

  • Loading branch information...
1 parent 7772c03 commit 1236ba59a1fd03350eb516960f922ef4c062126d @Baggz committed Mar 14, 2012
Showing with 12 additions and 0 deletions.
  1. +12 −0 src/engines/json/validateProperty.js
@@ -40,13 +40,25 @@ Validation.prototype.validateProperty = function(property, propertyValue, proper
// Overwrite the ‘addError’ method
context.addError = function(message) {
+
+ if (isObject(message)) {
+ return self.errors.push({
+ property: message.property || property,
+ propertyValue: message.propertyValue || propertyValue,
+ attributeName: message.attributeName || attributeName,
+ attributeValue: message.attributeValue || propertyAttributes[attributeName],
+ message: message.message || undefined
+ });
+ }
+
return self.errors.push({
property: property,
propertyValue: propertyValue,
attributeName: attributeName,
attributeValue: propertyAttributes[attributeName],
message: message
});
+
};
/**

0 comments on commit 1236ba5

Please sign in to comment.