Skip to content

Revalidate model after successful custom validation event broadcasted #642

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

Merged
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
3 changes: 3 additions & 0 deletions src/directives/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ angular.module('schemaForm').directive('sfField',
scope.ngModel.$setValidity(error, validity === true);

if (validity === true) {
// Re-trigger model validator, that model itself would be re-validated
scope.ngModel.$validate();

// Setting or removing a validity can change the field to believe its valid
// but its not. So lets trigger its validation as well.
scope.$broadcast('schemaFormValidate');
Expand Down
3 changes: 3 additions & 0 deletions src/services/decorators.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ angular.module('schemaForm').provider('schemaFormDecorators',
scope.ngModel.$setValidity(error, validity === true);

if (validity === true) {
// Re-trigger model validator, that model itself would be re-validated
scope.ngModel.$validate();

// Setting or removing a validity can change the field to believe its valid
// but its not. So lets trigger its validation as well.
scope.$broadcast('schemaFormValidate');
Expand Down