Skip to content

Commit

Permalink
FIX provider.setSuccess/ErrorMessage & no-validation-message
Browse files Browse the repository at this point in the history
no-validation-message has higher priority than provider set success/error message
  • Loading branch information
hueitan committed Nov 26, 2015
1 parent 440da13 commit 0946ed4
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 5 deletions.
16 changes: 14 additions & 2 deletions dist/angular-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,14 @@
if (scope.messageId) messageElem = angular.element(document.querySelector('#' + scope.messageId));
else messageElem = element.next();

if ($validationProvider.showSuccessMessage && messageToShow) messageElem.html($validationProvider.getSuccessHTML(messageToShow));
if (element.attr('no-validation-message')) {
messageElem.css('display', 'none');
} else if ($validationProvider.showSuccessMessage && messageToShow) {
messageElem.html($validationProvider.getSuccessHTML(messageToShow));
messageElem.css('display', '');
} else {
messageElem.css('display', 'none');
}

ctrl.$setValidity(ctrl.$name, true);
if (scope.validCallback) scope.validCallback({
Expand Down Expand Up @@ -376,8 +383,13 @@
if (scope.messageId) messageElem = angular.element(document.querySelector('#' + scope.messageId));
else messageElem = element.next();

if ($validationProvider.showErrorMessage && messageToShow) {
if (element.attr('no-validation-message')) {
messageElem.css('display', 'none');
} else if ($validationProvider.showErrorMessage && messageToShow) {
messageElem.html($validationProvider.getErrorHTML(messageToShow));
messageElem.css('display', '');
} else {
messageElem.css('display', 'none');
}

ctrl.$setValidity(ctrl.$name, false);
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-validation.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions src/validator.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@
if (scope.messageId) messageElem = angular.element(document.querySelector('#' + scope.messageId));
else messageElem = element.next();

if ($validationProvider.showSuccessMessage && messageToShow) messageElem.html($validationProvider.getSuccessHTML(messageToShow));
if (element.attr('no-validation-message')) {
messageElem.css('display', 'none');
} else if ($validationProvider.showSuccessMessage && messageToShow) {
messageElem.html($validationProvider.getSuccessHTML(messageToShow));
messageElem.css('display', '');
} else {
messageElem.css('display', 'none');
}

ctrl.$setValidity(ctrl.$name, true);
if (scope.validCallback) scope.validCallback({
Expand Down Expand Up @@ -52,8 +59,13 @@
if (scope.messageId) messageElem = angular.element(document.querySelector('#' + scope.messageId));
else messageElem = element.next();

if ($validationProvider.showErrorMessage && messageToShow) {
if (element.attr('no-validation-message')) {
messageElem.css('display', 'none');
} else if ($validationProvider.showErrorMessage && messageToShow) {
messageElem.html($validationProvider.getErrorHTML(messageToShow));
messageElem.css('display', '');
} else {
messageElem.css('display', 'none');
}

ctrl.$setValidity(ctrl.$name, false);
Expand Down
Loading

0 comments on commit 0946ed4

Please sign in to comment.