Skip to content
koinejsPublic

About

Simple data validation adapter

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

16 Commits

Folders and files

Repository files navigation

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

About

Simple data validation adapter

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages