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

Commit

Permalink
Add silent mode to checkFormValidity function
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Mar 10, 2017
1 parent 96bc98f commit b0c696b
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,5 @@ pip-log.txt

#Mr Developer
.mr.developer.cfg
yarn-error.log
yarn.lock
4 changes: 3 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ templates/
.gitignore
app.js
gulpfile.js
index.html
index.html
yarn-error.log
yarn.lock
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-validation-ghiscoding",
"version": "1.5.16",
"version": "1.5.17",
"author": "Ghislain B.",
"description": "Angular-Validation Directive and Service (ghiscoding)",
"main": [
Expand Down
8 changes: 4 additions & 4 deletions dist/angular-validation.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-validation-ghiscoding",
"version": "1.5.16",
"version": "1.5.17",
"author": "Ghislain B.",
"description": "Angular-Validation Directive and Service (ghiscoding)",
"main": "dist/angular-validation.min",
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Angular Validation (Directive / Service)
`Version: 1.5.16`
`Version: 1.5.17`
### Forms Validation with Angular made easy!
##### (Concept comes from the amazing Laravel)

Expand Down
2 changes: 1 addition & 1 deletion src/validation-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,7 @@ angular
if (_remotePromises.length > 1) {
while (_remotePromises.length > 0) {
var previousPromise = _remotePromises.pop();
if (typeof previousPromise.abort === "function") {
if (!!previousPromise && typeof previousPromise.abort === "function") {
previousPromise.abort(); // run the abort if user declared it
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/validation-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ angular
/** Check the form validity (can be called by an empty ValidationService and used by both Directive/Service)
* Loop through Validation Summary and if any errors found then display them and return false on current function
* @param object Angular Form or Scope Object
* @param bool silently, do a form validation silently
* @return bool isFormValid
*/
function checkFormValidity(obj) {
function checkFormValidity(obj, silently) {
var self = this;
var ctrl, elm, elmName = '', isValid = true;
if(typeof obj === "undefined" || typeof obj.$validationSummary === "undefined") {
Expand All @@ -166,10 +167,10 @@ angular

if(!!formElmObj && !!formElmObj.elm && formElmObj.elm.length > 0) {
// make the element as it was touched for CSS, only works in AngularJS 1.3+
if (typeof formElmObj.ctrl.$setTouched === "function") {
if (typeof formElmObj.ctrl.$setTouched === "function" && !silently) {
formElmObj.ctrl.$setTouched();
}
self.commonObj.updateErrorMsg(obj.$validationSummary[i].message, { isSubmitted: true, isValid: formElmObj.isValid, obj: formElmObj });
self.commonObj.updateErrorMsg(obj.$validationSummary[i].message, { isSubmitted: (!!silently ? false : true), isValid: formElmObj.isValid, obj: formElmObj });
}
}
}
Expand Down

0 comments on commit b0c696b

Please sign in to comment.