Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into CBX-262
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Lord committed May 15, 2014
2 parents 65dcb5b + fb9a5eb commit 8d25554
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions angular-activerecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,14 @@ angular.module('ActiveRecord', []).factory('ActiveRecord', ['$http', '$q', '$par
var errorMessage = this.$validationErrorMessages[functionName] || "is invalid";
if (angular.isFunction(errorMessage)) errorMessage = errorMessage(fieldName, fieldValue, validationValue);
if (typeof sprintf !== "undefined") {
errorMessage = sprintf(errorMessage, {fieldName: this.$fieldTranslations[fieldName] || fieldName, fieldValue: fieldValue, validationValue: validationValue});
if(!errorMessage.errorMessage){
errorMessage = sprintf(errorMessage, {fieldName: this.$fieldTranslations[fieldName] || fieldName, fieldValue: fieldValue, validationValue: validationValue});
} else {
errorMessage.fieldName = this.$fieldTranslations[fieldName] || fieldName;
errorMessage.fieldValue = fieldValue;
errorMessage.validationValue = validationValue;
errorMessage = sprintf(errorMessage.errorMessage, errorMessage);
}
}
return errorMessage;
},
Expand All @@ -335,11 +342,9 @@ angular.module('ActiveRecord', []).factory('ActiveRecord', ['$http', '$q', '$par
var props = typeof mthis[fieldName] == "object" ? mthis[fieldName] : [mthis[fieldName]];
var notEmptyValidation = false;
if (mthis.$validations[fieldName].notEmpty) {
if (mthis.$validations[fieldName].notEmpty !== true && mthis.$validations[fieldName].notNull) {
if (mthis.$validations[fieldName].notEmpty !== true) {
notEmptyValidation = mthis.$validations[fieldName].notEmpty;
} else if (mthis.$validations[fieldName].notEmpty) {
notEmptyValidation = mthis.$emptyValues();
} else if (mthis.$validations[fieldName].notNull) {
} else {
notEmptyValidation = mthis.$emptyValues();
}
}
Expand All @@ -350,7 +355,7 @@ angular.module('ActiveRecord', []).factory('ActiveRecord', ['$http', '$q', '$par
errors = mthis.$applyValidation(fieldName, prop, errors);
}
});
if (emptyError) {
if (emptyError && this.$validations[fieldName].notEmpty) {
errors.push(mthis.$getErrorMessage(fieldName, "notEmpty"));
}
} else if (this.$validations[fieldName].required) {
Expand Down

0 comments on commit 8d25554

Please sign in to comment.