Skip to content

Commit

Permalink
Show error message when the form is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
hueitan committed Jul 10, 2014
1 parent 3e8d44e commit 343f578
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
10 changes: 8 additions & 2 deletions dist/angular-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,21 @@
*/
this.validate = function (form) {

var idx = 0;
var deferred = $q.defer(),
idx = 0;

if (form === undefined) {
console.error('This is not a regular Form name scope');
deferred.reject('This is not a regular Form name scope');
return deferred.promise;
}

for (var k in form) {
if (form[k].hasOwnProperty('$dirty')) {
$scope.$broadcast(k + 'submit-' + form[k].validationId, idx++);
}
}

var deferred = $q.defer();
deferred.promise.success = function (fn) {
deferred.promise.then(function (value) {
fn(value);
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.

10 changes: 8 additions & 2 deletions src/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,21 @@
*/
this.validate = function (form) {

var idx = 0;
var deferred = $q.defer(),
idx = 0;

if (form === undefined) {
console.error('This is not a regular Form name scope');
deferred.reject('This is not a regular Form name scope');
return deferred.promise;
}

for (var k in form) {
if (form[k].hasOwnProperty('$dirty')) {
$scope.$broadcast(k + 'submit-' + form[k].validationId, idx++);
}
}

var deferred = $q.defer();
deferred.promise.success = function (fn) {
deferred.promise.then(function (value) {
fn(value);
Expand Down

0 comments on commit 343f578

Please sign in to comment.