Skip to content

Commit 434df4a

Browse files
committed
update readme
1 parent 2927bb7 commit 434df4a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ app.listen(5003);
5656

5757
## emptyInputCheck
5858

59-
This middleware validates all inputs to all routes (unless used at router level) by checking the **body** of both POST and GET requests.
59+
This middleware checks for all empty inputs to all routes (unless used at a router level) by checking the **body** of both POST and GET requests.
60+
61+
Note: 0 does count as a valid input.
62+
63+
All empty inputs will be met with a **400** and the message: `{ msg: 'Some fields are missing!' }`.
64+
65+
You can specify the middleware to skip the check for **GET** requests in the config option.
6066

6167
```javascript
6268
//Dependencies
@@ -69,7 +75,7 @@ const { emptyInputCheck } = require('../app');
6975
//Initialize the App
7076
const app = express();
7177

72-
// bodyParser Middleware
78+
//bodyParser Middleware
7379
app.use(
7480
bodyParser.json({
7581
limit: '5mb',
@@ -78,9 +84,11 @@ app.use(
7884
);
7985

8086
//The emptyInputCheck Middleware
87+
//It's important that we place the our middleware after the bodyParser middleware
88+
//Make sure you call the emptyInputCheck middleware before the routes are loaded
8189
app.use(
8290
emptyInputCheck({
83-
checkGet: true,
91+
checkGet: true, //Wether to check the GET requests or not
8492
}),
8593
);
8694

0 commit comments

Comments
 (0)