@dupkey/validator
v1.0.2
Published
Implement different validation libraries with a common response.
Downloads
1
Readme
@dupkey/validator
Implement different validation libraries with a common response interface.
Install
npm install @dupkey/validator
Example
import { JoiValidator } from '@dupkey/validator';
import * as Joi from 'joi';
let input = {
name: 'Ron Burgundy'
}
let rules = {
name: Joi.string().min(3).max(45).required()
};
let validator = new JoiValidator();
if (validator.validate(input, rules) === false) {
return validator.getErrors());
}
...
Build the TypeScript and JavaScript versions
npm run build
Run the tests
npm test
VS Code Debugging
Create a launch.json
file in your .vscode folder with the following:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Mocha Tests",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"--require", "ts-node/register",
"-u", "tdd",
"--timeout", "999999",
"--colors", "--recursive",
"${workspaceFolder}/test/**/*.ts"
],
"internalConsoleOptions": "openOnSessionStart"
}
]
}
In the debug tab (Ctrl+Shift+D) select "Mocha Tests" from the dropdown and then click "Start Debugging". Results will display in the console on the bottom of the VS Code.