Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow set with initial-validity / refire validators if updated #288

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion dist/angular-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ angular.module('validation.directive', ['validation.provider']);
* Set initial validity to undefined if no boolean value is transmitted
*/
var initialValidity = void 0;
if (typeof attrs.initialValidity === 'boolean') {
if (typeof attrs.initialValidity === 'boolean' || attrs.initialValidity ==='true' || attrs.initialValidity ==='false') {
initialValidity = attrs.initialValidity;
}

Expand All @@ -697,6 +697,8 @@ angular.module('validation.directive', ['validation.provider']);
*/
attrs.$observe('validator', function(value) {
validation = value.split(',');
var theValue = useViewValue ? ctrl.$viewValue : ctrl.$modelValue;
checkValidation(scope, element, attrs, ctrl, validation, theValue);
});

/**
Expand Down
5 changes: 4 additions & 1 deletion src/validator.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@
* Set initial validity to undefined if no boolean value is transmitted
*/
var initialValidity = void 0;
if (typeof attrs.initialValidity === 'boolean') {
if (typeof attrs.initialValidity === 'boolean' || attrs.initialValidity ==='true' || attrs.initialValidity ==='false') {
initialValidity = attrs.initialValidity;
}

Expand All @@ -319,6 +319,9 @@
*/
attrs.$observe('validator', function(value) {
validation = value.split(',');
// validation has been updated => make rule fire again
var theValue = useViewValue ? ctrl.$viewValue : ctrl.$modelValue;
checkValidation(scope, element, attrs, ctrl, validation, theValue);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests fail because the checkValidation will be called in the initialization phase, it should trigger only there is a change on validator.

});

/**
Expand Down