Skip to content
This repository was archived by the owner on Jul 1, 2020. It is now read-only.
Merged
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
Changes done in 2 methods in validation-service.js
changes done in attemptToValidate (line number 339) method and removeWatcherAndErrorMessage (line number 494) method
  • Loading branch information
PrashantP25 authored Jun 8, 2019
commit 8380c0efb3cbfb264ed9e163b846df335649b2e2
9 changes: 6 additions & 3 deletions src/validation-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,12 @@ angular
// pre-validate without any events just to pre-fill our validationSummary with all field errors
// passing false as 2nd argument for not showing any errors on screen
self.commonObj.validate(value, false);


// check field level setting for validateOnEmpty
var isFieldValidateOnEmpty = (self.commonObj.validatorAttrs && self.commonObj.validatorAttrs.validateOnEmpty);

// if field is not required and his value is empty, cancel validation and exit out
if(!self.commonObj.isFieldRequired() && !_validateOnEmpty && (value === "" || value === null || typeof value === "undefined")) {
if(!self.commonObj.isFieldRequired() && !(_validateOnEmpty || isFieldValidateOnEmpty) && (value === "" || value === null || typeof value === "undefined")) {
cancelValidation(self, formElmObj);
deferred.resolve({ isFieldValid: true, formElmObj: formElmObj, value: value });
return deferred.promise;
Expand Down Expand Up @@ -491,7 +494,7 @@ angular
var foundWatcher = self.commonObj.arrayFindObject(_watchers, 'elmName', formElmObj.fieldName);
if(!!foundWatcher) {
foundWatcher.watcherHandler(); // deregister the watch by calling his handler
_watchers.shift();
self.commonObj.arrayRemoveObject(_watchers, 'elmName', formElmObj.fieldName);
}

// make the validation cancelled so it won't get called anymore in the blur eventHandler
Expand Down