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
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