Skip to content

Commit

Permalink
Fix checkValid error
Browse files Browse the repository at this point in the history
  • Loading branch information
lvarayut committed Oct 21, 2015
1 parent 6f9403d commit 465263f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
5 changes: 1 addition & 4 deletions dist/angular-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,7 @@
* @returns {boolean}
*/
this.checkValid = function(form) {
if (form.$valid === undefined) {
return false;
}
return (form && form.$valid === true);
return !!(form && form.$valid);
};


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.

5 changes: 1 addition & 4 deletions src/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,7 @@
* @returns {boolean}
*/
this.checkValid = function(form) {
if (form.$valid === undefined) {
return false;
}
return (form && form.$valid === true);
return !!(form && form.$valid);
};


Expand Down
3 changes: 3 additions & 0 deletions test/unit/providerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ describe('provider', function() {
expect(validationProvider.checkValid($scope.Form)).toBe(true);
$scope.Form.required.$setViewValue('');
expect(validationProvider.checkValid($scope.Form)).toBe(false);
delete $scope.Form;
expect(validationProvider.checkValid($scope.Form)).toBe(false);
expect(validationProvider.checkValid()).toBe(false);
}));

it('reset', inject(function() {
Expand Down

0 comments on commit 465263f

Please sign in to comment.