Skip to content

Commit

Permalink
Merge pull request #242 from Availity/hotfix/issue-237
Browse files Browse the repository at this point in the history
Fix invalid error messges on page load for form validation
  • Loading branch information
robmcguinness committed Sep 15, 2016
2 parents e921d2b + 15affa8 commit 9b70e78
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/core/validation/validator.js
Expand Up @@ -92,7 +92,7 @@

var ruleConfig = rules[key];
if(!ruleConfig) {
$log.error('Failed to get rules key [' + key + ']. Forms must be tagged with a rules set name for validation to work.');
$log.warn('Could not resolve the form rules key [' + key + ']. This can happen when the rules key is inside a promise and the key value has not resolved on page load.');
return;
}

Expand Down
16 changes: 12 additions & 4 deletions lib/ui/validation/field.js
Expand Up @@ -79,10 +79,18 @@
var rulesKey = self.avValForm.rulesKey;
var results = avVal.validate(rulesKey, $element, value, self.rule);

// validate function is called within the context of angular so fn.call and set the context
// to "this"
self.updateModel.call(self, results);
self.updateView.call(self);

// Results can be undefined if the form validation key is not resolved on page load due
// to promises. When the promise resolves the validation on the form should re-run with
// valid results.
if(results) {

// The validate function is called within the context of angular so fn.call and set the context
// to "this"
self.updateModel.call(self, results);
self.updateView.call(self);

}

return results;
};
Expand Down

0 comments on commit 9b70e78

Please sign in to comment.