Skip to content

Latest commit

 

History

History
68 lines (40 loc) · 1.73 KB

README.md

File metadata and controls

68 lines (40 loc) · 1.73 KB

Koine Validator

Validator adapter for letting you use whathever awesome validation lib you want.

Code information:

Build Status Coverage Status Code Climate

Package information:

Dependency Status

Usage

In order to create a validator, extend the executeValidation method:

var UserValidation = function () {};
UserValidator.prototype = Koine.Validator.prototype;
UserValidator.prototype = Koine.Validator.prototype.executeValidation = function (value) {
        if (!value['name']) {
            this.getErrors().add('name', 'you must set name');
        }

        if (!value['lastName']) {
            this.getErrors().add('lastName', 'you must set last name');
        }
    };

var user = { name: 'Jon', lastName: '' };

var validator = new UserValidator();


validator.isValid(user); // false

validator.getErrors();
// { lastName: ['last name cannot be empty'] }

user.lastName = 'Doe';

validator.isValid(user); // true

Installing

@TODO

Issues/Features proposals

Here is the issue tracker.

Contributing

Please refer to the contribuiting guide.

Lincense

MIT

Authors