Skip to content

Commit

Permalink
npi validator should pass if value is empty, null or undefined
Browse files Browse the repository at this point in the history
* fixes #184
  • Loading branch information
Rob McGuinness committed Jan 23, 2016
1 parent fe6899e commit 3a836fc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/core/validation/validators/tests/validator-npi-spec.js
Expand Up @@ -10,10 +10,10 @@ describe('avValNpi', function () {
avValNpi = _avValNpi_;
}));

it('should NOT validate if NPI is empty, undefined or null', function () {
expect(avValNpi.validate(undefined)).toBe(false);
expect(avValNpi.validate('')).toBe(false);
expect(avValNpi.validate(null)).toBe(false);
it('should validate if NPI is empty, undefined or null', function () {
expect(avValNpi.validate(undefined)).toBe(true);
expect(avValNpi.validate('')).toBe(true);
expect(avValNpi.validate(null)).toBe(true);
});

it("should NOT validate if NPI contains non-digits", function() {
Expand Down
1 change: 1 addition & 0 deletions lib/core/validation/validators/validator-date-format.js
Expand Up @@ -13,6 +13,7 @@
return avValUtils.isEmpty(value) || moment(value, format, true).isValid();
}
};

return validator;
});
})(window);
6 changes: 5 additions & 1 deletion lib/core/validation/validators/validator-npi.js
Expand Up @@ -4,7 +4,7 @@

var availity = root.availity;

availity.core.factory('avValNpi', function() {
availity.core.factory('avValNpi', function(avValUtils) {


var validator = {
Expand All @@ -17,6 +17,10 @@

var npi = value || '';

if(avValUtils.isEmpty(npi)) {
return true;
}

if (!validator.INTEGER_REGEX.test(npi) || npi.length !== 10) {
return false;
}
Expand Down

0 comments on commit 3a836fc

Please sign in to comment.