validation unit tests for validation > validator presence plus small refactor on validator

This commit is contained in:
Carlos Jimenez 2018-01-02 08:26:46 +01:00
parent 12b3342953
commit 86630be398
2 changed files with 1 additions and 2 deletions

View File

@ -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>`;

View File

@ -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`);
}, },