Skip to content

koinejs/Validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

Watchers

Forks

Releases

No releases published

Packages

No packages published