Skip to content
This repository was archived by the owner on Jul 1, 2020. It is now read-only.

Commit b0c696b

Browse files
committed
Add silent mode to checkFormValidity function
1 parent 96bc98f commit b0c696b

8 files changed

+17
-12
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,5 @@ pip-log.txt
222222

223223
#Mr Developer
224224
.mr.developer.cfg
225+
yarn-error.log
226+
yarn.lock

.npmignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ templates/
66
.gitignore
77
app.js
88
gulpfile.js
9-
index.html
9+
index.html
10+
yarn-error.log
11+
yarn.lock

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-validation-ghiscoding",
3-
"version": "1.5.16",
3+
"version": "1.5.17",
44
"author": "Ghislain B.",
55
"description": "Angular-Validation Directive and Service (ghiscoding)",
66
"main": [

dist/angular-validation.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-validation-ghiscoding",
3-
"version": "1.5.16",
3+
"version": "1.5.17",
44
"author": "Ghislain B.",
55
"description": "Angular-Validation Directive and Service (ghiscoding)",
66
"main": "dist/angular-validation.min",

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Angular Validation (Directive / Service)
2-
`Version: 1.5.16`
2+
`Version: 1.5.17`
33
### Forms Validation with Angular made easy!
44
##### (Concept comes from the amazing Laravel)
55

src/validation-common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,7 @@ angular
13351335
if (_remotePromises.length > 1) {
13361336
while (_remotePromises.length > 0) {
13371337
var previousPromise = _remotePromises.pop();
1338-
if (typeof previousPromise.abort === "function") {
1338+
if (!!previousPromise && typeof previousPromise.abort === "function") {
13391339
previousPromise.abort(); // run the abort if user declared it
13401340
}
13411341
}

src/validation-service.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,10 @@ angular
146146
/** Check the form validity (can be called by an empty ValidationService and used by both Directive/Service)
147147
* Loop through Validation Summary and if any errors found then display them and return false on current function
148148
* @param object Angular Form or Scope Object
149+
* @param bool silently, do a form validation silently
149150
* @return bool isFormValid
150151
*/
151-
function checkFormValidity(obj) {
152+
function checkFormValidity(obj, silently) {
152153
var self = this;
153154
var ctrl, elm, elmName = '', isValid = true;
154155
if(typeof obj === "undefined" || typeof obj.$validationSummary === "undefined") {
@@ -166,10 +167,10 @@ angular
166167

167168
if(!!formElmObj && !!formElmObj.elm && formElmObj.elm.length > 0) {
168169
// make the element as it was touched for CSS, only works in AngularJS 1.3+
169-
if (typeof formElmObj.ctrl.$setTouched === "function") {
170+
if (typeof formElmObj.ctrl.$setTouched === "function" && !silently) {
170171
formElmObj.ctrl.$setTouched();
171172
}
172-
self.commonObj.updateErrorMsg(obj.$validationSummary[i].message, { isSubmitted: true, isValid: formElmObj.isValid, obj: formElmObj });
173+
self.commonObj.updateErrorMsg(obj.$validationSummary[i].message, { isSubmitted: (!!silently ? false : true), isValid: formElmObj.isValid, obj: formElmObj });
173174
}
174175
}
175176
}

0 commit comments

Comments
 (0)