This repository was archived by the owner on Dec 21, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
44 lines (37 loc) · 1.75 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
var stringValidator = require('validator');
var ValidationError = require('./lib/error/validationError.js');
var ValidationMultiError = require('./lib/error/validationMultiError.js');
var ValidatorManager = require('./lib/validatorManager.js');
var Validator = require('./lib/validator.js');
var expressMiddleware = require('./lib/expressMiddleware.js');
var expressInjectorMiddleware = require('./lib/expressInjectorMiddleware.js');
var composeError = require('./lib/composeError.js');
var assertions = require('./lib/assertions.js');
var sanitizers = require('./lib/sanitizers.js');
var conditions = require('./lib/conditions.js');
var validatorManager = new ValidatorManager;
/**
* define
*
* initiates and registers new validator object in cache
*
* @param {string} name - name of the validator
* @param {Object|Function} schema - validation schema
* @param {Object} [options] - see Validator options for more details
*
* @return {Validator}
*/
module.exports.define = function(name, schema, options) {
var validator = new Validator(schema, options, validatorManager);
validatorManager.add(name, validator);
return validator;
}
module.exports.Validator = Validator;
module.exports.ValidationError = ValidationError;
module.exports.ValidationMultiError = ValidationMultiError;
module.exports.ValidatorManager = ValidatorManager;
module.exports.getExpressInjector = expressInjectorMiddleware;
module.exports.getExpressMiddleware = expressMiddleware;
module.exports.error = composeError;
module.exports.validators = assertions;
module.exports.sanitizers = sanitizers;