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

Commit ce22370

Browse files
authored
Merge pull request #178 from mgm09a/master
Fixed revalidateAndAttachOnBlur method to handle zeroes appropriately
2 parents 1f455c8 + 134accc commit ce22370

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/validation-directive.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
}
180180

181181
// invalidate field before doing any validation
182-
if(!!value || commonObj.isFieldRequired() || _validateOnEmpty) {
182+
if((value !== "" && value !== null && typeof value !== "undefined") || commonObj.isFieldRequired() || _validateOnEmpty) {
183183
ctrl.$setValidity('validation', false);
184184
}
185185

@@ -403,7 +403,9 @@
403403
/** Re-evaluate the element and revalidate it, also re-attach the onBlur event on the element */
404404
function revalidateAndAttachOnBlur() {
405405
// Revalidate the input when enabled (without displaying the error)
406-
var value = ctrl.$modelValue || '';
406+
var value = ctrl.$modelValue !== null && typeof ctrl.$modelValue !== 'undefined'
407+
? ctrl.$modelValue
408+
: '';
407409
if(!Array.isArray(value)) {
408410
ctrl.$setValidity('validation', commonObj.validate(value, false));
409411
}

0 commit comments

Comments
 (0)