Skip to content

Commit e790b5f

Browse files
SenthilBalajiSenthilBalaji
authored andcommitted
added license and documentation
1 parent efe978e commit e790b5f

File tree

2 files changed

+72
-5
lines changed

2 files changed

+72
-5
lines changed

LICENSE.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2016 KBLNY
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.

readme.md

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,52 @@
1-
## Developing a validation mechanism for node-express applications
1+
# express-input-validation
22

3-
Released version-1 still unstable and in development.
3+
![npm version](https://img.shields.io/npm/v/express-validator.svg)
44

5-
- one stable version is released for now.
6-
- refer example for how to use.
7-
- documentation coming soon.
5+
An [express.js]( https://github.com/visionmedia/express ) middleware for input validation.
6+
7+
express-input-validation is simple yet powerful node module that makes your API robust and discard any request with invalid input.
8+
9+
- [Installation](#installation)
10+
- [Features](#features)
11+
- [Examples](#examples)
12+
- [License](#license)
13+
14+
## Installation
15+
```
16+
npm install express-input-validation
17+
```
18+
OR
19+
```
20+
yarn add express-input-validation
21+
```
22+
## Features
23+
you can ask `express-input-validation` to get value from any of these(following list) using `from` key in rules array,
24+
25+
- Header (header)
26+
- Query (query)
27+
- Body (body)
28+
- Params (param)
29+
30+
and can pass any custom validation function using `validation_function` in the rules array. Also you can pass a `message` in rules for particular rule or it'll be default send a `invalid ${key_name}` as message.
31+
32+
## Example
33+
Following are the example for validating using `express-input-validation`, here I have included all four type of inputs that most commonly an API can have:
34+
35+
```
36+
{
37+
"from": "query",
38+
"key": "emailId",
39+
validation_function: value => value.indexOf("@") > -1
40+
}
41+
```
42+
43+
In rules array the above one can be one of the objects, here I've showed a custom `validation_function` without message, this ll return `Invalid emailId` incase the email id is not found or if it doesn't have an `@` in the value string.
44+
45+
# Note
46+
- `key`, `from` are required keys in object in all of the rule you define.
47+
- a rule without a `validation_function` is considered to be only `required` field, i.e., `express-input-validation` only checks if there is a field in specified `from` key in the object.
48+
- for more examples
49+
50+
## License
51+
52+
MIT License

0 commit comments

Comments
 (0)