validation unit tests for validation > validator presence plus small refactor on validator
This commit is contained in:
parent
12b3342953
commit
86630be398
|
@ -34,7 +34,6 @@ describe('Directive validation', () => {
|
||||||
}).toThrow(new Error(`vnValidation: Entity 'User' doesn't exist`));
|
}).toThrow(new Error(`vnValidation: Entity 'User' doesn't exist`));
|
||||||
});
|
});
|
||||||
|
|
||||||
// should adapt the test to whathver needs to test the user name instead of mail validation as it should be in mail-validation.js
|
|
||||||
describe('Validator Presence()', () => {
|
describe('Validator Presence()', () => {
|
||||||
it('should not validate the user name as it is an empty string', () => {
|
it('should not validate the user name as it is an empty string', () => {
|
||||||
let html = `<form><input type="name" ng-model="user.name" vn-validation="user.name"/></form>`;
|
let html = `<form><input type="name" ng-model="user.name" vn-validation="user.name"/></form>`;
|
||||||
|
|
|
@ -5,7 +5,7 @@ export const validators = {
|
||||||
if (validator.isEmpty(value))
|
if (validator.isEmpty(value))
|
||||||
throw new Error(`Value can't be empty`);
|
throw new Error(`Value can't be empty`);
|
||||||
},
|
},
|
||||||
absence: function(value, conf) {
|
absence: value => {
|
||||||
if (!validator.isEmpty(value))
|
if (!validator.isEmpty(value))
|
||||||
throw new Error(`Value should be empty`);
|
throw new Error(`Value should be empty`);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue