epochtalk-validator
Validation module for epochtalk and epochcore
Last updated 5 years ago by wangbus .
MIT · Original npm · Tarball · package.json
$ cnpm install epochtalk-validator 
SYNC missed versions from official npm registry.

Validator

Schema validation module for all Epoch Projects.

Installation

$ git clone git@github.com:epochtalk/validator
$ cd validator
$ npm install

Usage Example

Access predefined validation methods

var authValidator = require('validator').api.auth; // Access the auth validator within api

var credentials = {
  username: 'test_user',
  password: 'password'
};

var err = authValidator.login(credentials); // pass parameters in to validator

if(err) {
  // do error related things
}
else {
  // do success related things
}

Directly access predefined Joi Schema

var authSchemas = require('validator').api.auth.schema; // Access Auth Schema
var Joi = require('joi');

var credentials = {
  username: 'test_user',
  password: 'password'
};

var loginSchema = authSchema.login; // grab the auth login schema

var err = Joi.validate(credentials, loginSchema); // Manually call Joi.validate with schema

if(err) {
  // do error related things
}
else {
  // do success related things
}

Current Tags

  • 0.0.5                                ...           latest (5 years ago)

5 Versions

  • 0.0.5                                ...           5 years ago
  • 0.0.4                                ...           5 years ago
  • 0.0.3                                ...           5 years ago
  • 0.0.2                                ...           6 years ago
  • 0.0.1                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (3)
Dev Dependencies (0)
None

Copyright 2014 - 2017 © taobao.org |