From ca0f1bd1c0e03ae1e021c0f43674faa113241b20 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 May 2014 11:57:22 -0400 Subject: [PATCH 1/2] CBX-35 - Fix notEmpty validation --- angular-activerecord.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/angular-activerecord.js b/angular-activerecord.js index aad7603..728bbc7 100644 --- a/angular-activerecord.js +++ b/angular-activerecord.js @@ -335,11 +335,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(); } } @@ -350,7 +348,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) { From 5fa74d739b1e3e1a1d0d0ab70e83d6a4d721bc18 Mon Sep 17 00:00:00 2001 From: Alexandre Lord Date: Thu, 15 May 2014 09:52:06 -0400 Subject: [PATCH 2/2] =?UTF-8?q?CBX-48=20Permettre=20des=20messages=20d'err?= =?UTF-8?q?eur=20avec=20des=20param=C3=A8tres.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- angular-activerecord.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/angular-activerecord.js b/angular-activerecord.js index aad7603..5dbc466 100644 --- a/angular-activerecord.js +++ b/angular-activerecord.js @@ -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; },